I wonder if some of the expert OLE users could comment on what problem I'm
having.

I'm trying to write a small server which finds .doc files, opens them, saves
as .rtf, and then closes the file.
Easy enough you'd think!

Anyway, it works one or twice, or even a half dozen times, but eventually it
will not close the application and I end up with a WinWord running that I
can't close except with the task manager. I even enabled visible but can't
close it from the system box. This process sits there running 100% CPU and
keeps the file open? 

I was having problems with the $doc->Close() as it kept giving me an error
about no window to close so I took that out and went back to calling quit()
on the application.  (The Password is supplied as the only way I could find
to bypass the password prompt for a password secured file, if there is no
password required it does not appear to care what you put, and if there is
one required then you get a nice error return rather than an nasty prompt).




Here is the basics of the script: (I even changed it to close word everytime
instead of just closing the document).

     $Word = Win32::OLE->new('Word.Application', 'Quit');
     my $doc = $Word->Documents->Open({
          FileName => "$INBOUND_FILE_DIR\\$filename", 
          ConfirmConversions => 0,
          ReadOnly => 1,
          PasswordDocument => 'abc',
          Visible => 0
        } );
    if ( !$doc ) {
        print("Unable to open document ", Win32::OLE->LastError());
        HideFile( $filename );
        return;
    }

    $doc->SaveAs( { FileName=>"${filename_base}.rtf",
FileFormat=>wdFormatRTF } );

    $doc->Close(  ) or print "**** we could not close the document: ",
Win32::OLE->LastError();

    $Word->quit();
    undef($Word);
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to