Page 1 of 1

Variable in COM name

Posted: 26 Jul 2015, 16:12
by gilliduck
I'm sure my terminology is wrong, but I'm wanting to have a variable in a COM object, but I'm getting invalid name errors.

Code: Select all

wb2.Document.All.%user_pass%.value := "11111"
the %user_pass% is my variable obviously, but the format doesn't appear to play well with this. Is there a way to do what I want or am I just screwing up the syntax elsewhere and that's why I'm getting an error?

Re: Variable in COM name

Posted: 26 Jul 2015, 16:39
by gilliduck
NVM, think I got it

wb2.Document.All.(user_pass).value := "11111"

Re: Variable in COM name

Posted: 27 Jul 2015, 00:43
by jethrow
See the all property. When in doubt, try the call in javascript. Any of the following are appropriate:

Code: Select all

document.all(user_pass)
document.all[user_pass]
document.all.item(user_pass)