*... >If type("oWordDocument") = "U" > Public oWordDocument >Endif >If type("gHwndWord") = "U" > Public gHwndWord >Endif > >Declare integer GetForegroundWindow in WIN32API >Declare short IsWindow in WIN32API integer > >******************** >* Create word object >******************** >If type("oWordDocument") = "O" ; > and type("gHwndWord") = "N" ; > and IsWindow(gHwndWord) # 0 && Check if word window is alive > oWordDocument=getobject(, "Word.application") && Create word object >Else > oWordDocument=createobject("word.application") && Create word object >Endif >******************** >* Create word object >******************** > >With oWordDocument > * .... > .visible = .t. && Show word app > .Activate && Make word active window >Endwith >gHwndWord = GetForegroundWindow() && Save word window handle >Do while IsWindow(gHwndWord) # 0 && Wait while Word is alive >Enddo >Clear dlls >oWordDocument=.Null.Cetin