# If Word is closed instead of the file, calling "Count" # causes an error message but lowering the Warn level # eliminates it. $mydocnt = $word->Documents->Count(); $word->{Visible} = 1; $word->{WindowState} = wdWindowStateMaximize; $warnlevel = $Win32::OLE::Warn; $Win32::OLE::Warn=1; Win32::MsgBox("After printing, close the file\.",vbOKOnly); $done = 0; while ($done == 0) { if ($word->Documents) { if (($mycnt = $word->Documents->Count()) != $mydocnt) { $done = 1; } } else { undef $word; $word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application'); $done = 1; } sleep 5; }