Word Automation
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
I am using word automation to get the text in a word document however, i face problems when the document is already open. Is there a way (coding) to check if that document is open and if open, close it?
Try below code.
Word::_ApplicationPtr wdPtr; Word::_Application::get_Application( &wdPtr); if ( NULL == wdPtr ) wdPtr.CreateInstance(__uuidof(Word::Application)); for (int i=0; iDocuments->Count; i++) { Word::_DocumentPtr dPtr = wdPtr->Documents->Item(i); if ( dPtr->Name == "whatever you are looking for" ) dPtr->Close(); }
cheers ..milton kb