I need a reference or a method for looking up syntax details for COM methods. Is there such a reference or a Matlab command that would serve?
1 view (last 30 days)
Show older comments
In the current case, I am looking for detail on GetSaveAsFilename. The MSDN VBA developer reference has detail, but the format is wrong for Matlab. I'd like to set a filter, default filename, etc.
0 Comments
Answers (1)
Guillaume
on 10 Oct 2016
Assuming you're talking about the GetSaveAsFilename method of the Excel Application object, the MSDN documentation is the best reference you're going to find I'm afraid.
In the case of GetSaveAsFilename I can't find anything wrong, missing or that would cause problem when written in matlab:
excelapp = actxsever('Excel.Application');
excelapp.Visible = true; %otherwise you can't see the dialog!
filename = excelapp.GetSaveAsFilename('somename.txt', 'Text Files (*.txt), *.txt, Add-In Files (*.xla), *.xla', 2, 'Some Title');
%or with less options:
filename = excelapp.GetSaveAsFilename('somename.txt');
filename = excelapp.GetSaveAsFilename();
The one issue you will encounter with the MSDN documentation is that it does not give you the value of the many excel constants and matlab does not know anything about the constant names. In which case, the object browser in excel vba editor is very useful. For example , you can search for xlFileFormat (one of optional inputs of the Workbook.Save method) in the object browser and see all the possible values (e.g. xlOpenXMLWorkbook has value 51).
Another useful tool is matlab's methodsview (or command line methods) which lets you see the signature expected by matlab.
4 Comments
Steven Lord
on 10 Oct 2016
This section on the page Guillaume linked seems relevant. It suggests that your second input is not in the format that GetSaveAsFilename requires.
This string passed in the FileFilter argument consists of
pairs of file filter strings followed by the MS-DOS wildcard
file filter specification, with each part and each pair
separated by commas. Each separate pair is listed in the
Files of type drop-down list box. For example, the following
string specifies two file filters, text and addin:
"Text Files (*.txt), *.txt, Add-In Files (*.xla), *.xla".
After creating the excelapp object as Guillaume did, try:
excelapp.GetSaveAsFilename('foo', ...
'Microsoft Excel spreadsheet (*.xlsx), *.xlxs', ...
[], 'Select/ define power analysis output file')
See Also
Categories
Find more on Enterprise Deployment with MATLAB Production Server in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!