Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters > C/C++
Register

Reply
 
LinkBack Thread Tools
Old 17.08.2006, 13:16   #1
Младенец
 
Join Date: 08 2006
Location: Currently in Germany.
Posts: 2
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default How to steer the Word documents in already opened Word application.

Hi,

I have the following question. I’m writing the program in C++, which is
opening in background the Word document, modifying and then closing it. Till
now each document has been opened with separate Word application and after
modification has been closed:
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 want to open Word application only once, and then in consecutive order
open, manipulate and close the documents.

Of course I can check whether “winword.exe” process existing or not and also
read the PID, but how can I steer the document?
Reply With Quote
Old 17.08.2006, 18:08   #2
Младенец
 
Join Date: 08 2006
Location: Currently in Germany.
Posts: 2
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default How can I get access to the already opened Word application?

Dear Colleagues,

I found that my question was not presented very clear. I'll try to explain it better.

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.



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
Reply With Quote
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 03:16.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.