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 次查看(过去 30 天)
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.

回答(1 个)

Guillaume
Guillaume 2016-10-10
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 个评论
Steven Lord
Steven Lord 2016-10-10
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')

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Enterprise Deployment with MATLAB Production Server 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by