sub CheckMarkup { # document must be saved unless ($ActiveDocument->{Saved}) { $Application->Alert("Document must be saved before checking"); return; } # document must be valid unless ($ActiveDocument->{IsValid}) { $Application->Alert("Document must be valid before checking (run Validate)"); return; } # get the path to this document my $path = $ActiveDocument->{FullName}; # run the check script my $shell = Win32::OLE->new('WScript.Shell'); unless ($shell) { $Application->Alert("Can't make WScript.Shell object"); return; } $shell->Run("I:\\...\\check.bat \"$path\"", 5); }