Quantcast
Channel: Word for Developers forum
Viewing all articles
Browse latest Browse all 4350

Word automation issue

$
0
0
Hi,

I am using Visual C++ 6 to automate Word.  During the WindowDeactivate event I search the active word docs using some FindWindow code (below).  When it finds it, if it is the document that was generated by my app, it sends a Quit message to Word.  The in the quit handler, I save the document to various places.

SOMETIMES it comes up with a "File In Use" message. I can't find out why it is doing this or how to prevent it.

BOOL CFindWindow::Find(CString csWindowTitle)
{
//First use Find Window to see if there are any instances running ....
DWORD dwThreadId = GetCurrentThreadId(); // Get the current thread id
HDESK hDesktop = GetThreadDesktop(dwThreadId); // Assign the desktop thread id to hDesktop

g_bFound = FALSE;
g_iFoundCount = 0;

g_csWindowToFind = csWindowTitle;


g_csWindowTitleFound = "";

EnumDesktopWindows( hDesktop, FindWindowInstance, 0 );


return g_bFound;
}



Viewing all articles
Browse latest Browse all 4350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>