"Andrei" <pr**********@hotmail.com> wrote in news:003b01c3770f$d95a89b0
$a*******@phx.gbl:
Hello,
I posted yesterday the same problem, but now I want to be
more specific about it.
My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.
If I use GetObject to get a reference to Word object (of
course that Word applicaton is started) I get an error
("Cannot create ActiveX component")
It is like my service cannot detect that Word application
is started.
I want to say that GetObject is working fine from a
standard Windows application.
Thank you,
Andrei
I'm unclear as to what is working and what is not for you? Are you
saying GetObject() works for getting the reference to the application,
but not other classes inside the application? Getobject() is only for
getting a reference to the application. You don't use it to get a
Document class instance. instead use the Documents property of the
Application instance!
Here is the code I use to get a reference to an application object in
AutoCAD. This should be very similar for a Word application:
mcadApplication = (AutoCAD.AcadApplicationClass)
Marshal.GetActiveObject("AutoCAD.Application");
It works similarly to GetObject.
--
Michael Lang, MCSD