Excel COM Server, create Autofilter

조회 수: 12 (최근 30일)
Daniel
Daniel 2011년 8월 25일
Hi, I'm writing a script starting an Excel COM-Server and inserting some data into a sheet. This is works fine but in addition I'm searching for a command to create an Autofilter for a selected Row.
Does anyone know how I can achieve this? I'm searching for a function reference as I'm not very familiar with COM/ActiveX etc. (I also want to fix my window on a certain cell...)
Any help is welcome :)

채택된 답변

Friedrich
Friedrich 2011년 8월 25일
Hi,
A good way to get the function and command you need it to open Excel and let EXCEL record a macro for you. Simply click on start recording macro, do manually what you like to do in EXCEL and hit stop recording. After recording is done you can look at the VB code which gives you all needed functions and commands.

추가 답변 (2개)

Daniel
Daniel 2011년 8월 25일
Some more example code:
e = actxserver ('Excel.Application');
e.Visible = 1;
%eWorkbook = e.Workbooks;
e.Workbooks.Add;
sheet1=e.Worksheets.get('Item', 'Sheet1');
range1 = get(sheet1,'Range','A1:EM671');
range1.Value = arr;
range1 = get(sheet1,'Range','C4');
range1.Select;
e.ActiveWindow.FreezePanes = 1;
range1 = get(sheet1,'Range','3:3');
range1.Select;range1.AutoFilter
  댓글 수: 1
Friedrich
Friedrich 2011년 8월 25일
Thanks for posting the working code. +1

댓글을 달려면 로그인하십시오.


Daniel
Daniel 2011년 8월 25일
Thank you very much! This helps me a lot the code is
Rows("3:3").Select
Selection.autofilter

카테고리

Help CenterFile Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by