wyldtek has asked for the wisdom of the Perl Monks concerning the following question:
use Win32::OLE; use Win32::OLE::Enum; use Win32::OLE::Variant; use Win32::OLE::Const; use File::Find; use vars qw($MSWord $wd $startdir); $MSWord=Win32::OLE->new('Word.Application','Quit') or die "Could not load MS Word"; $wd=Win32::OLE::Const->Load($MSWord); unless (open CONFIG, "H:\\perl\\config.txt") { die "Cannot open config file: $!"; } @config_lines = <CONFIG>; my $doc = Win32::OLE -> GetObject("H:\\perl\\Functional Design Templat +e r1.6 baseline.doc"); $paragraphs = $doc->Paragraphs(); $enumerate = new Win32::OLE::Enum($paragraphs); foreach $config_line (@config_lines) { $heading = (split(/===/, $config_line))[0]; print $heading."\n"; while(defined($paragraph = $enumerate->Next())) { $paragraph->{Range}->{Find}->{Text}=($heading."^p"); $paragraph->{Range}->{Find}->Execute({FindText=>$wd,Forward=>$ +wd->{True}}); my $output = $paragraph->{Range}->{Find}->Found; print $output."\n"; } } print "DONE"; $doc->Close({SaveChanges=>$wd->{wdSaveChanges}});
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OLE Find with Paragraphs()
by tachyon (Chancellor) on Jun 11, 2004 at 06:34 UTC | |
by Discipulus (Canon) on Jun 11, 2004 at 08:33 UTC | |
by wyldtek (Initiate) on Jun 11, 2004 at 15:20 UTC | |
by tachyon (Chancellor) on Jun 14, 2004 at 23:29 UTC | |
by wyldtek (Initiate) on Jun 15, 2004 at 15:28 UTC |