I am on window xp
I am trying to save a doc file in .htm format,below code is working but with some issues
It close all the word file open in the system.
is there any way to open and close only single doc
----------------------------------------
#!perl -w
use strict;
use File::Find;
find(\&save_as_html, "C:\\abc");
sub save_as_html
{
use Win32::OLE qw(in with);
use Win32::OLE::Const;
use Win32::OLE::Const 'Microsoft Word';
$Win32::OLE::Warn = 3;
my $filename = $File::Find::name;
my $savename = "$filename".".htm";
if (( -f $filename ) && (rindex (substr ($filename,-4,4),".doc") =
+= 0 )) {
print "Starting word\n";
my $Word = Win32::OLE->GetActiveObject('Word.Application')
or Win32::OLE->new('Word.Application', 'Quit');
$Word->{Visible}= 0;
print "Opening $filename \n";
$Word->Documents->Open( $filename )
or die("Unable to open document ", Win32::OLE->LastError()
+);
print "Saving $filename "."as $savename\n";
$Word->ActiveDocument->SaveAs({
FileName => $savename,
FileFormat => 8});
print "Closing document\n";
$Word->ActiveDocument->save( $filename );
$Word->ActiveDocument->save( $savename );
#$Word->Quit;
}
}