Jump to content

How ommit a parameter in a COM Method?


Recommended Posts

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

Link to comment
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

Link to comment
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

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

Link to comment
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

Link to comment
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)
Edited by Uten
Link to comment
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
Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
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)")

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

  • 7 years later...

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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...