Sign in to follow this  
Followers 0
mikeqf

COM syntax question

5 posts in this topic

Hi all. I'm updating a script from vbscript to AutoIt, and I'm having some trouble with the formatting of some COM commands. In the script, I am using the COM interface for Excel, Access, and SMS. I've "translated" most of the code with no issue. The problem occurs when I try to run a couple of commands in particular.

VBScript: (works perfectly)
Collection.AddMembershipRule CollectionRule
AutoIt: (does not work)
$Collection.AddMembershipRule $CollectionRule

VBScript: (works perfectly)
objaccess.docmd.transferspreadsheet 1,8,"Query","spreadsheet.xls",True
AutoIt: (does not work)
$ObjAccess.DoCmd.TransferSpreadsheet 1,8,"Query","spreadsheet.xls",True

I get the same error when AutoIt attempts to run these lines: "Error: The requested action with this object has failed." Every other COM command I run works fine. The difference is that none of the others have spaces in them. I'm guessing that is the issue. Anyone have any idea how I can format this so AutoIt can process it? I've tried different variations of quotation marks, parentheses, but I just can't get it. Thanks!

Share this post


Link to post
Share on other sites



Try

$Collection.AddMembershipRule($CollectionRule)

$ObjAccess.DoCmd.TransferSpreadsheet(1,8,"Query","spreadsheet.xls",True)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

$Collection.AddMembershipRule($CollectionRule)

Worked great. I thought I had tried it like that, but I guess not!

$ObjAccess.DoCmd.TransferSpreadsheet(1,8,"Query","spreadsheet.xls",True)

Still doesn't work. I also tried the below, and it didn't work either:

$transfer = '1,8,"Query","spreadsheet.xls",True'
$ObjAccess.DoCmd.TransferSpreadsheet($transfer)

Anyone have any other ideas? Thanks!

Edited by mikeqf

Share this post


Link to post
Share on other sites

$Collection.AddMembershipRule($CollectionRule)

Worked great. I thought I had tried it like that, but I guess not!

$ObjAccess.DoCmd.TransferSpreadsheet(1,8,"Query","spreadsheet.xls",True)

Still doesn't work. I also tried the below, and it didn't work either:

$transfer = '1,8,"Query","spreadsheet.xls",True'
$ObjAccess.DoCmd.TransferSpreadsheet($transfer)

Anyone have any other ideas? Thanks!

<{POST_SNAPBACK}>

Mike,

AutoIt doesn't support the keywords false/true.

You could replace 'true' with numeric 1 and 'false' with numeric 0.

$ObjAccess.DoCmd.TransferSpreadsheet(1,8,"Query","spreadsheet.xls",1)

However I'm not sure if TransferSpreadsheet() will accept this kind of substitution.

Regards,

-Sven

Share this post


Link to post
Share on other sites

Thanks Sven,

That did it for me.

$ObjAccess.DoCmd.TransferSpreadsheet(1,8,"Query","spreadsheet.xls",1)

Worked great!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0