Jump to content
Sign in to follow this  

There must be an easier way to define a variable object property

Recommended Posts

I'm looking for a simple way to get an object property defined in a variable.

$o = ObjCreate("InternetExplorer.Application")
$o.visible = 1

Dim $title1, $title2, $title3
$sProperty = "title"

$title1 = $o.document.title
$title2 = Execute("$o.document." & $sProperty)
;~ $title3 = $o.document.$sProperty     ; uncomment to see the error

ConsoleWrite("Title1: " & $title1 & @CRLF)
ConsoleWrite("Title2: " & $title2 & @CRLF)
ConsoleWrite("Title3: " & $title3 & @CRLF)


Title1 is the hardcoded way.

Title2 is using a variable and Execute() function.

Please uncomment Title3 and get the error.

There must be a simpler method to get a variable property than using Execute().

Any ideas ?

UDF: _SingleScript()                                        If you like my post, just click the like button :)        here -->

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  

  • Create New...