As sgifford says the easy way is just to use OLE to automate MS Word. You will need M$ Word installed for this to work of course. All we do is open the works doc in Word, then save it as wdFormatDocument. This example will convert all *.wps Works docs in the specified directory.
use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; my $dir = "C:"; my $ext = "wps"; my @files = map{ s!/!\\!g; $_ } grep{ m/\.($ext)/ } glob( "$dir/*" ); # check if Word exists and is running my $word = Win32::OLE->GetActiveObject('Word.Application'); die "Word not Installed" if $@; # start Word program instance if required or die if unable to unless (defined $word) { $word = Win32::OLE->new('Word.Application', sub { $_[0]->Quit; } ) + or die 'Cannot start Word'; } $word->{Visible} = 0; # set to 1 to watch for my $infile( @files ) { my $doc = $word->{Documents}->Open($infile) or die "Can't open $infile, Reason:$Win32::OLE::LastError"; (my $outfile = $infile ) =~ s/\.\w+$/.doc/; # change file extensi +on to .doc $doc->SaveAs( { FileName => $outfile, FileFormat => wdFormatDocume +nt } ); $doc->Close; undef $doc; } $word->Close; undef $word;
cheers
tachyon
In reply to Re: Microsoft Works
by tachyon
in thread Microsoft Works
by straywalrus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |