if type('pgHwndWord')="U"
DECLARE integer GetForegroundWindow in WIN32API
DECLARE integer SetForegroundWindow in WIN32API integer
DECLARE short IsWindow in WIN32API integer
public pgHwndWord,poWordApplication
endif
if empty(pgHwndWord) or ! iswindow(pgHwndWord)=1
**technically better to say "or iswindow(pgHwndWord)!=1 "
** create WORD server
poWordApplication= createobject("word.application")
poWordApplication.visible = .t.
** maximize WORD
poWordApplication.windowstate = 1
poWordApplication.activate
pgHwndWord = GetForegroundWindow() && Save word window handle
else
SetForegroundWindow(pgHwndWord)
endif