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

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

[Octave-bug-tracker] [bug #60098] Package: windows: Unable to skip optio


From: N Kando
Subject: [Octave-bug-tracker] [bug #60098] Package: windows: Unable to skip optional arguments in COM objects
Date: Mon, 22 Feb 2021 09:37:12 -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

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

                 Summary: Package: windows: Unable to skip optional arguments
in COM objects
                 Project: GNU Octave
            Submitted by: itskando
            Submitted on: Mon 22 Feb 2021 02:37:10 PM UTC
                Category: Octave Forge Package
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Unexpected Error or Warning
                  Status: None
             Assigned to: None
         Originator Name: itskando
        Originator Email: 
             Open/Closed: Open
                 Release: 6.1.0
         Discussion Lock: Any
        Operating System: Microsoft Windows

    _______________________________________________________

Details:

Using empty brackets to skip optional arguments always fails. User on octave
forums has possibly identified source of problem and also determined
solution.

Issue, possible source of problem, and possible solution described here:

https://octave.discourse.group/t/package-windows-unable-to-skip-optional-arguments-in-com-objects-possible-bug/798

.
.
.

The following minimal working example below fails when attempting to skip
optional arguments using empty braces.

Expected usage syntax described here:

https://www.mathworks.com/help/matlab/matlab_external/using-methods.html


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.add('[]',sht);  % fails
shts.add('[]',wsht); % fails


shts.count

wbk.save;

srvr.quit;



Here is the error:


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


Note that the `add` functions until skipping the first input. Are square
brackets the wrong method to skip an input?

.
.
.

Suggestion from other user:

MSDN: [Office Automation Using Visual C++
(microsoft.com)](https://support.microsoft.com/en-us/topic/office-automation-using-visual-c-67da40c2-7671-f700-474d-36ac522d76f2)

If I read point 6 correctly, optional arguments that are skipped should be
passed with the following value in C++:


      // VARIANT used in place of optional-parameters.
      VARIANT varOpt;
      varOpt.vt = VT_ERROR;
      varOpt.scode = DISP_E_PARAMNOTFOUND;


The COM interface in the windows package seems to use the following instead:


  else if (ov.is_real_matrix () && ov.OV_ISEMPTY ())
  {
    var->vt = VT_EMPTY;
  }


That might be the reason for this not working.




    _______________________________________________________

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]