How can I get access to the already opened Word application?

S

Suren

Dear Colleagues,

Firs of all I should mention that I’m faraway from COM and OLE programming,
but now I'm working on one project and I guess I need to learn that.

The problem is following. I have a Windows service, which is working
according to some algorithm. From time to time it creates the process, runs
the MS Word application, opens the Word document, manipulates it and then
closes the document and Word application.

Something like that:

CApplication objWord;
if(!objWord.CreateDispatch("Word.Application"))
......
CDocuments docs(objWord.get_Documents());
doc.AttachDispatch(docs.Open(....));
......
docs.Close(covFalse,covOptional,covOptional);
objWord.Quit(covFalse,covTrue,covFalse);

Now I should increase the speed of this process. I have found that starting
the Word application consumed most of the time. Therefore I have decided to
open the Word application only once and then, when it is necessary, open and
manipulate the Word documents.

The only information I have is PID (PROCESS_INFORMATION) of the process,
created by CreateProcess.

My question is following.

How can I get access to the already opened Word application, open there the
Word document and manipulate it.

Thank you in advance,

Suren Karabekyan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top