>Hi Naomi,
>That worked. So for a summary to anyone else reading this thread, this is what worked:
>Word:
>.ioServer.Application.WindowState = 2 && i.e. minimized; note: maximized is 1 if needed
>.ioServer.Application.WindowState = 0 && i.e. normal
>* where .ioServer is the Word object
This also works with Word, and without flickering the window. It is the method suggested on an MSDN discussion where someone asked how to access Word's HWND. You need to have the root Word.Application object, however, as in "lo" below.
You can verify this by copying-and-pasting this code into VFP9 in a test.prg and single-stepping through it:
lo = CREATEOBJECT("word.application")
lo.Visible = .t.
DECLARE INTEGER FindWindow IN WIN32API STRING cClass, STRING cName
lcOldCaption = lo.Caption
lcNewCaption = SYS(2023) + "Changed to something unique momentarily to find only me"
lo.Caption = lcNewCaption
lnHwnd = FindWindow(NULL, lcNewCaption)
lo.Caption = lcNewCaption
DECLARE INTEGER BringWindowToTop IN WIN32API INTEGER hWnd
DECLARE INTEGER ShowWindow IN WIN32API INTEGER hWnd, LONG nCmdShow
ShowWindow(lnHwnd,1)
BringWindowToTop(lnHwnd)
>Excel:
>* this one uses Win32 functions to bring the window forward
>DECLARE INTEGER BringWindowToTop IN WIN32API INTEGER hWnd
>DECLARE INTEGER ShowWindow IN WIN32API INTEGER hWnd, LONG nCmdShow
>ShowWindow(.ioServer.HWnd,1)
>BringWindowToTop(.ioServer.HWnd)
>* where .ioServer is the Excel object