sub save_doc_as_text { my ( $infile, $outfile ) = @_; print "\n$infile"; print "\n$outfile"; require Win32::OLE; my $word = Win32::OLE->new( 'Word.Application', sub {$_[0]->Quit;}); error( "Can't create new instance or Word Reason:$Win32::OLE::LastError" ) unless $word; $word->{visible} = 0; my $doc = $word->{Documents}->Open($infile); error( "Can't open $infile, Reason:$Win32::OLE::LastError" ) unless $doc; # wdFormatDocument wdFormatText wdFormatHTML $doc->SaveAs( { FileName => $outfile, FileFormat => $wdFormatText}); $doc->Close; undef $doc; undef $word;} $inf="ole-word-demo-3.doc"; $outf="ole-word-demo-3.txt"; save_doc_as_text($inf,$outf);