Hi all,

at one time we had a discussion here about whether you could tell if an app
was running, and if it was if you could connect to it, using getObject.  I
came away from that discussion thinking that no, getObject did not let you
know if something was already running, and connect you to it if it was.

Today I found docs from Microsoft which said it does just that.  the trick
is not to pass an empty string as the first parameter, but omit the first
parameter  altogether.  

indeed, when I tried it, it works perfectly, telling me if Word is running
or not, and connecting me to it  if it is, and it's a lot easier than trying
to use .nativeObjectModel.

Just try this in immediate mode:

when Word is not running: set W=getObject(, "word.application")

and you'll get an error, and Word will not start.

Now, start Word and try it.  no error, and you can make Word be visible to
you by: w.visible = true

proving you're connected.

You'll have to surround this with onerror commands, since if the app isn't
running you get an error.

Really, it seems much better than nativeObjectModel for working with the
same session as the user is.

hth,

Chip

Reply via email to