choose Excel Com Server Version

5 次查看(过去 30 天)
Martin1986
Martin1986 2012-1-26
I try to choose which excel version should create the output i have installed both 2003 and 2007 i check with regedit # HKEY_CLASSES_ROOT\Excel.Application # HKEY_CLASSES_ROOT\Excel.Application.11 # HKEY_CLASSES_ROOT\Excel.Application.12
switch typ
case 1
[file,path] = uiputfile('*.xls','Save selected data');
Excel = actxserver('Excel.Application.11');
case 2
[file,path] = uiputfile('*.xlsx','Save selected data');
Excel = actxserver('Excel.Application.12');
otherwise
return;
end fileName=fullfile(path,file);
if ~exist(fileName,'file')
ExcelWorkbook = Excel.workbooks.Add;
ExcelWorkbook.SaveAs(fileName)
ExcelWorkbook.Close(false);
end
ExcelWorkbook = Excel.workbooks.Open(fileName);
for case 1 it works fine case 2 not
??? Invoke Error, Dispatch Exception: Source: Microsoft Office Excel Description: Die Open-Methode des Workbooks-Objektes konnte nicht ausgeführt werden. Help File: C:\Programme\Microsoft Office\OFFICE11\1031\xlmain11.chm Help Context ID: 0
Error in ==> dataSave at 25 ExcelWorkbook = Excel.workbooks.Open(fileName);
Error in ==> Velo2Xls>save_Callback at 321 dataSave(handles.time, handles.outdata, outHeader);
??? Error while evaluating uicontrol Callback
any ideas?

回答(0 个)

类别

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