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") && get instance Else oWordDocument=createobject("word.application") && Create word object Endif ******************** * Create word object ******************** With oWordDocument *... Endwith gHwndWord = GetForegroundWindow() && Save word window handle Do while IsWindow(gHwndWord) # 0 && Wait while Word is alive Enddo Clear dlls oWordDocument=.Null.Cetin