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')
David Conway
David Conway 2016 年 10 月 10 日
Guillaume, Steven, That did it! Thank you. I think I get it now... I missed the display string text part.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnterprise 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