Sign in to follow this  
Followers 0
GioVit

How ommit a parameter in a COM Method?

18 posts in this topic

I'm working with excel COM object and I need to Skip (ommit) a parameter in a Function that add a new Worksheet. The parameters of the funtion are:

Function Add([Before], [After], [Count], [Type]) As Object

so if I want to Add a worksheet after the $o_worksheet object, in the $o_workbook object I need to set the parameters this way

$o_newWorksheet = $o_workbook.Worksheets.Add([ommited param], $o_worksheet)

But this si not allowed in Autoit and I cant find a value that emulate a null parameter.

BTW if I Set both Parameters [before] and [After] I get an Error

Any suggestion?

Thanks in advance

Share this post


Link to post
Share on other sites



Is the Add function a AutoIt function? Or is it a method on a object you have created earlier?

The function declaration and the sample does not seem to match at all in my eyes. But I don't know mutch about com in AutoIt :D

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Is the Add function a AutoIt function? Or is it a method on a object you have created earlier?

The function declaration and the sample does not seem to match at all in my eyes. But I don't know mutch about com in AutoIt :D

Have you tried "" (that two if these: ") ?

Dale

Edit: typo

Edited by DaleHohm

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Have you tried "" (that two if these: ") ?

Dale

Edit: typo

Yes I Tried with "" and get an error and it is an object method, Uten

but I solved it by "moving" the sheet before the next 2 sheet

Thanks DaleHohm and Uten

but I think AutoIt should offer a way to skip parameters

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Dont you have to use another calling convention if you want to skip parameters?

In an excel script you would do something like this (If I recall right):

objX = object.Add("After:= 1, Type:=" & struct.something)
Edited by Uten

Share this post


Link to post
Share on other sites

Dont you have to use another calling convention if you want to skip parameters?

In an excel script you would do something like this (If I recall right):

objX = object.Add("After:= 1, Type:=" & struct.something)
Yes I tried it too but is not allowed in AutoIt or if so, I don't know how to apply

Share this post


Link to post
Share on other sites

I mean if I write

$o_worksheet = $o_worbook.Workbooks.Add('After := "Sheet1"')

I'll get a COM Error

Share this post


Link to post
Share on other sites

Leaves me all out of ides :D

Sorry.

it's Ok many thanks anyway

Share this post


Link to post
Share on other sites

I mean if I write

$o_worksheet = $o_worbook.Workbooks.Add('After := "Sheet1"')
oÝ÷ ØýXµ 0J뢿êº^¬¶¬³)ík(®F®¶­s`¢b33c¶õ÷v÷&·6VWBÒb33c¶õõÂåv÷&&öö·2äFBgV÷C´gFW#£Õ6VWCgV÷C²

This assumes that $o_XL is your Excel.Application automation object. This is the syntax I would assume after looking at the object docs.

Dale

ps. also consider adding a COM error handler to get more specifics about the error.


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

The Default keyword is used to skip parameters in COM calls:

$o_newWorksheet = $o_workbook.Worksheets.Add(Default, $o_worksheet)
Edited by Valik

Share this post


Link to post
Share on other sites

@DaleHohm, @Valik

none of both suggestion work.

I'm trying to program a new ExcelUDF, here are the source code it is incomplete but what I'm testing until now is working, if you want to try it here is the source code, install both files in the same directory.

The error in question is in line # 261 of ExcelUDF.au3 and if you want to find some solution you must coment lines 262, 263, 264.

Thank you

ExcelUDF_Test.au3

ExcelUDF.au3

Share this post


Link to post
Share on other sites

@DaleHohm, @Valik

none of both suggestion work.

I'm trying to program a new ExcelUDF, here are the source code it is incomplete but what I'm testing until now is working, if you want to try it here is the source code, install both files in the same directory.

The error in question is in line # 261 of ExcelUDF.au3 and if you want to find some solution you must coment lines 262, 263, 264.

Thank you

Have you tried the command in VBScript? Show a small working example in VBScript and we'll have more to work with.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Have you tried the command in VBScript? Show a small working example in VBScript and we'll have more to work with.

Dale

in VBScript work with this format

Worksheets.Add  After:=Sheets(1)

but I don't know how to apply this kind of parameter assignment into Autoit ("After:=Sheet(1)")

Share this post


Link to post
Share on other sites

in VBScript work with this format

Worksheets.Add  After:=Sheets(1)

but I don't know how to apply this kind of parameter assignment into Autoit ("After:=Sheet(1)")

That's just one line of code. If you'll provide a small stand-alone example in VBScript I'm willing to experiment and try to help.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

That's just one line of code. If you'll provide a small stand-alone example in VBScript I'm willing to experiment and try to help.

Dale

Sub Macro1()
'
' Macro1 Macro
' Macro grabada el 11/06/2006 por GioVit
'

'
    Sheets("Sheet1").Select
    Sheets.Add After:=Sheets(1)
    Sheets.Add After:=Sheets("Sheet3")
End Sub

After and Before Parameters are of type Worksheet

This is VBA Code Inside an Excel Macro and I don't know if it differ with code in VBScript, because I have never used VBScript

Share this post


Link to post
Share on other sites

This is an exert from autoit documentation.

To skip an optional parameter, leaving its default value intact, use:
    "" for string parameters
    -1 for numeric parameters

 

Share this post


Link to post
Share on other sites

Welcome to AutoIt and the forum!

You have noticed that the thread is nearly 8 years old and the OP has been offline for 3 1/2 years?

Please don't necro old threads :naughty:


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2016-07-20 - Version 1.2.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0