none
Word automation issue RRS feed

  • General discussion

  • 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;
    }


    • Moved by Elegentin Xie Thursday, June 13, 2013 6:20 AM from Visual C++, to a more appropriate forum
    • Changed type Quist ZhangModerator Wednesday, June 26, 2013 8:17 AM not actually word specific
    Wednesday, June 12, 2013 3:57 PM

All replies