in reply to OLE Find with Paragraphs()
It is hard to see exactly what you are trying to do. By far the easiest way to do this is to convert the doc to a text file. The either slurp it in and split it into paras or set $/ ="\n\n" and read it in one para at a time. This sub will do the conversion for you.
my $wdFormatText = 2; # wdFormatText constant from Win32::OLE::Co +nst 'Microsoft Word' sub convert_doc_to_text { my ( $infile, $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::LastE +rror")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; } sub error { die shift }
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: OLE Find with Paragraphs()
by Discipulus (Canon) on Jun 11, 2004 at 08:33 UTC | |
|
Re^2: OLE Find with Paragraphs()
by wyldtek (Initiate) on Jun 11, 2004 at 15:20 UTC | |
by tachyon (Chancellor) on Jun 14, 2004 at 23:29 UTC | |
|
Re^2: OLE Find with Paragraphs()
by wyldtek (Initiate) on Jun 15, 2004 at 15:28 UTC |