get current Instance of Word

  • Thread starter Thread starter Jazper Manto
  • Start date Start date
J

Jazper Manto

hi

i want to open a document in word by my app. therefore i wrote some code.

Type tWordApp = Type.GetTypeFromProgID("Word.Application");
Word.ApplicationClass oWordApp = (Word.ApplicationClass)
Activator.CreateInstance(tWordApp);

the probem is that i get a complete new instance even when the user already
opend the word before starting my application. so i'm looking for a solution
to check fist if there are currently any instances of the word application.
does anybody know how to do that?
thank you! jazper m.
 
Jazper,

I believe that the office applications register themselfs with the ROT
(Running Objects Table)
and you possibly could retreive it from there. Luckly there is a static
method on the Marshal
class to do this

Marshal.GetActiveObject()

Pass it the prodid of the object you want to fetch and go nuts =) You could
also start digging
through the ROT with the UCOMIRunningObjectTable.EnumRunning method.

HTH,

//Andreas
 
Did you try Activator.GetObject() method ?
no. because i did not find a method like that by intelisense...
however i'll try it too...
jazper
 
Back
Top