gpt4 book ai didi

excel - Octave:无法将可选参数传递给 VBA 函数(通过 COM 服务器添加 excel 表时)

转载 作者:行者123 更新时间:2023-12-04 20:23:36 25 4
gpt4 key购买 nike

我正在尝试将工作表添加到 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, 0, 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 中发布了这个.

最佳答案

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

关于excel - Octave:无法将可选参数传递给 VBA 函数(通过 COM 服务器添加 excel 表时),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66298526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com