I have in hand some code which converts an MS-Word .doc
file to
a text file.How do I change this code to do the reverse
i.e.convert from text to .doc format?
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;});er
+ror( "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 $d
+oc;
# wdFormatDocument wdFormatText wdFormatHTML
$doc->SaveAs( { FileName => $outfile, FileFormat => $wdFormatText});
+
$doc->Close;
undef $doc;
undef $word;}
$inf="C:\\test\\input3.doc";
$outf="C:\\test\\text-output.txt";
save_doc_as_text($inf,$outf);
Please help.
Thanx