Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Problem using Excel's Add method with ActiveX

Subject: Problem using Excel's Add method with ActiveX

From: francis.favorini@NOSPAMduke.edu (Francis Favorini)

Date: 29 Sep, 1998 21:13:16

Message: 1 of 4

How do I use the parameters of the Add method using ActiveX with MATLAB 5.2?
Here is the syntax from the Excel help file:

Syntax

expression.Add(Before, After, Count, Type)

expression Required. An expression that returns a Sheets object.

Before Optional Variant. An object that specifies the sheet before which the
         new sheet is added.

After Optional Variant. An object that specifies the sheet after which the
         new sheet is added.

Count Optional Variant. The number of sheets to be added. The default value
         is one.

Type Optional Variant. Specifies the sheet type. Can be one of the
         following XlSheetType constants: xlWorksheet, xlChart,
         xlExcel4MacroSheet, or xlExcel4IntlMacroSheet. The default value is
         xlWorksheet.

This works (and adds a new sheet before hSheet):

invoke(hWorksheets,'add',hSheet);

I can't figure out how to specify After instead of Before. I tried the
following and they all give errors:

invoke(hWorksheets,'add',[],hSheet);
invoke(hWorksheets,'add',{},hSheet);
invoke(hWorksheets,'add',{[],hSheet});
invoke(hWorksheets,'add',hSheet,hSheet);

-Francis

Subject: Problem using Excel's Add method with ActiveX

From: Chris Norman

Date: 30 Sep, 1998 13:26:33

Message: 2 of 4

Francis Favorini wrote:
>
> How do I use the parameters of the Add method using ActiveX with MATLAB 5.2?
> Here is the syntax from the Excel help file:
>
> Syntax
>
> expression.Add(Before, After, Count, Type)

I don't think you'll be able to specify just an "After" parameter with
MATLAB. The method assumes that the client/controller supports something
called "named" arguments, where you can pass values for only the
parameters in which you're interested by explicitly naming the
parameters in the method call (as opposed to positional arguments, where
the arguments are matched to parameter by their position in the argument
list). MATLAB, like a number of other automation controllers, doesn't
support named arguments.

This is the first time I have seen a method which is totally dependent
on this feature, and I was actually quite surprised when I first saw it.

--
Chris Norman mailto:cnorman@mathworks.com
The Mathworks, Inc. Phone:508-647-4287
24 Prime Park Way mailto:info@mathworks.com
http://www.mathworks.com Natick, Ma. 01760-1560

Subject: Problem using Excel's Add method with ActiveX

From: francis.favorini@NOSPAMduke.edu (Francis Favorini)

Date: 30 Sep, 1998 21:46:18

Message: 3 of 4

In article <361269C9.709E@mathworks.com>, cnorman@mathworks.com says...
>I don't think you'll be able to specify just an "After" parameter with
>MATLAB. The method assumes that the client/controller supports something
>called "named" arguments, [...]
>MATLAB, like a number of other automation controllers, doesn't
>support named arguments.

Darn. I was afraid of that.

Here's my ActiveX wish list so far:
+GetObject ActiveX function to allow selecting an open instance of Excel.
+Allow ActiveX collections to be indexed (as in hXL.Workbooks(1).name).
+Allow ActiveX collections to be indexed with strings (hXL.Workbooks('Book2'))
+Allow ActiveX method invocation with parameters using . notation (as in
hXL.doit(1,2))
+Allow ActiveX calls to use named arguments (might use structs or cell array
or just pass Nan or [] for args to ignore?)

Any chance on any of these happening? ;-) Should I officially submit these?

>This is the first time I have seen a method which is totally dependent
>on this feature, and I was actually quite surprised when I first saw it.

It is rather odd...

-Francis

[Posted and emailed.]

Subject: Problem using Excel's Add method with ActiveX

From: Chris Norman

Date: 1 Oct, 1998 16:14:04

Message: 4 of 4

Francis Favorini wrote:
>
> Here's my ActiveX wish list so far:
> +GetObject ActiveX function to allow selecting an open instance of Excel.
> +Allow ActiveX collections to be indexed (as in hXL.Workbooks(1).name).
> +Allow ActiveX collections to be indexed with strings (hXL.Workbooks('Book2'))
> +Allow ActiveX method invocation with parameters using . notation (as in
> hXL.doit(1,2))
> +Allow ActiveX calls to use named arguments (might use structs or cell array
> or just pass Nan or [] for args to ignore?)
>
> Any chance on any of these happening? ;-) Should I officially submit these?

Thanks for the feedback - I've added these to our enhancement request
database.

--
Chris Norman mailto:cnorman@mathworks.com
The Mathworks, Inc. Phone:508-647-4287
24 Prime Park Way mailto:info@mathworks.com
http://www.mathworks.com Natick, Ma. 01760-1560

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us