Closing document in Word under Automation
COM
1
Posts
1
Posters
0
Views
1
Watching
-
I'm using Word Automation (using C++ here) as an out of proc exe to Find and Replace text within documents. When I create an instance of Word I would prefer to keep that instance open and then open, search/replace, close and repeat until I am finished with all documents and then quit the word application instance. I have this working but I have an odd (or maybe it is a common) problem. When I close the document, Word becomes visible. Here's how I am closeing the document.
void CMSWord9Automation::CloseDoc() { try { if(m_pOpenDoc) // Word::_DocumentPtr { //m_pWord->Visible = VARIANT_FALSE; // Does not work m_pWord->Documents->Close( &_variant_t(Word::wdDoNotSaveChanges), &_variant_t(vtMissing), &_variant_t(VARIANT_FALSE)); //m_pWord->Visible = VARIANT_FALSE; // This resets word to invisible but isn't really the desired approach m_pOpenDoc.Release(); } } catch(_com_error& ComError) { DumpComError(ComError); } }
I'm looking for any information on how to stop Word from displaying when I close the opened document. Thanks, Dave Dak Lozar Loeser When access is allowed to a member, it said to be accessible. Otherwise, it is inaccessible. - MSDN:C# Programmer's Reference