How to selectExcel columns through Matlab activeX control?
6 次查看(过去 30 天)
显示 更早的评论
In Excel VBA I can create groups by using:
Columns(3).Resize(, 4).Group
This will make columns 3 through 7 into a group. In Matlab I have:
XL = actxserver('excel.application');
XL.DisplayAlerts = 0;
XL.Visible = 0;
XLWB = XL.Workbooks;
WB = Add(XLWB);
WS = WB.Worksheets;
AS = WB.ActiveSheet;
... bunch of stuff added to the sheet
At this point I want to group some columns. I have all the following and all have failed.
AS.Columns(3).Select
WS.Columns(3).Select
WS.Range.Columns(3).Select
What's the proper way to do this?
采纳的回答
更多回答(1 个)
Guillaume
2015-5-22
编辑:Guillaume
2015-5-22
I don't have time to test if that's the issue (particularly since you've not said what the failure is), but with matlab sometimes you can use the dot notation, and sometimes you can't because matlab fails to find the method. In these cases you have to use invoke.
Does this work?
invoke(As.Columns(3), 'Select');
edit: Actually, isn't the issue with your indexing of the range returned by Columns. With Matlab, you can't directly use brackets to index into collections. You have to use the Item property to get individual elements:
As.Columns.Item(3).Select
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 ActiveX 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!