Octave:无法将可选参数传递到 VBA 函数中通过 COM 服务器添加 Excel 表时

问题描述

我正在尝试将工作表添加到 Excel 文件中。

它应该相当简单;但是,当尝试使用空大括号跳过可选参数时,下面的最小工作示例失败。 (这不正确吗?Source 1 Source 2

clc
clear

% if COM error occurs,excel process remains open.
% use task manager to end process,else 'a.xlsx' file remains "in use".

srvr = actxserver('excel.application');
wbks = srvr.workbooks;

pth  = fullfile(pwd,'a.xlsx');

if ~exist(pth,'file')

  wbk = wbks.add;
  wbk.activate;
  wbk.saveAs( pth );
  wbk.close;

end

wbk = wbks.open( pth,false );
wbk.activate;

wshts    = wbk.worksheets;

shts     = wbk.sheets;

wsht     = wshts.item(1);
wsht.activate;

sht      = shts.item(1);

wsht.select(true);
sht.select(true);

%{
https://docs.microsoft.com/en-us/office/vba/api/excel.sheets.add
https://docs.microsoft.com/en-us/office/vba/api/excel.worksheets.add
%}

shts.add(sht);     % functions
shts.add(wsht);    % functions

shts.add([],sht);  % fails
shts.add([],wsht); % fails


shts.count

wbk.save;

srvr.quit;

这里是错误

error: com_invoke: property/method invocation on the COM object Failed with error `0x800a03ec' - Z
error: called from
    trash at line 46 column 1

请注意,add 会在跳过第一个输入之前起作用。方括号是跳过输入的错误方法吗?

Original source

我也在 Octave forum 发布了这个。

解决方法

根据问题下的评论,
这是一个错误,由 OP 和 has been reported fixed in the development branch 提供。