Home All Groups Group Topic Archive Search About

How to access desired instance of app when multiple running?

Author
25 Feb 2007 7:31 PM
Ken Krupa
GetObject gets the first instance of a program when there are more than one
open. I can determine whether it's the one that I want. But if not, is there
any way to get at another instance?

Here's what I've got for accessing AutoCAD R2007:
  Dim acadApp As Object
  On Error Resume Next
  Set acadApp = GetObject(, "AutoCAD.Application.17")

BTW, working with VB6 on XP2.

Author
25 Feb 2007 11:42 PM
Ralph
Show quote Hide quote
"Ken Krupa" <KenKr***@discussions.microsoft.com> wrote in message
news:A2CEFA08-3182-4419-8E77-E76985D151C7@microsoft.com...
> GetObject gets the first instance of a program when there are more than
one
> open. I can determine whether it's the one that I want. But if not, is
there
> any way to get at another instance?
>
> Here's what I've got for accessing AutoCAD R2007:
>   Dim acadApp As Object
>   On Error Resume Next
>   Set acadApp = GetObject(, "AutoCAD.Application.17")
>
> BTW, working with VB6 on XP2.

Short answer is - you can't. At least not reliably, and not all the time.

GetObject has a form where it allows you to call a specific document.
   Set oObj = GetObject("c:\somedoc.doc")
and it will get the instance that has that doc open. If more than one do,
then it is a crapshoot. (Sometimes opening it if not.)

I don't know if this form will even work with AutoCad.

Also appreciate that the behavior an ActiveX exe might display varys widely
among applications and other factors may have impact. For example, it may
depend on whether your program initially opened the app or whether the user
did.

This, while not dealing specifically with AutoCad might provide some
insight...
http://support.microsoft.com/kb/288902
(Appreciate that GetObject was written to support Office products.)

You probably will need to check out the automation documentation for your
specific version of AutoCad. As well as just test and see.

-ralph