octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #60098] [octave forge] (windows) Unable to ski


From: N Kando
Subject: [Octave-bug-tracker] [bug #60098] [octave forge] (windows) Unable to skip optional arguments in COM method invocation
Date: Mon, 22 Feb 2021 15:59:33 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36

Follow-up Comment #7, bug #60098 (project octave):

The code was probably antiquated when I posted it.

Here's my most up to date:


% if COM error, excel process remains open.
% use task manager to end process.

if exist('wbks', 'var')

if wbks.count > 0
  wbks.close;
end

release(srvr);

end

clc
clear

% setup
pkg('load', 'windows') % COM objects (for interfacing with office VBA)

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

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

if exist(pth, 'file')

  delete( pth );

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

end

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


wshts     = wbk.worksheets;
wsht{1,1} = wshts.item(1);
wsht{1,1}.activate;
wsht{1,1}.select(true);

shts     = wbk.sheets;
sht{1,1} = shts.item(1);
sht{1,1}.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
https://www.mathworks.com/help/matlab/matlab_external/insert-a-spreadsheet-after-sheet-1.html
%}

wshts0.label = { 'Apple' 
                 'Banana'
                 'Clementine'
               };

for i0 = 2 : size( wshts0.label, 1)

  switch 0

  case 0; shts.add(                   sht{1,1} ); % functions
  case 1; shts.add(                  wsht{1,1} ); % functions

  case 2; shts.add(             '[]', sht{1,1} ); % fails
  case 3; shts.add(              [] , sht{1,1} ); % fails
  case 4; com_invoke(shts,'add','[]','sht{1,1}'); % fails

  end

end


for i0 = 1 : size( wshts0.label, 1)
sht{i0,1}      = shts.item(i0);
sht{i0,1}.name = wshts0.label{i0,1};
end

wbk.save;
wbks.close;
release(srvr)


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60098>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]