rootstock has asked for the wisdom of the Perl Monks concerning the following question:
i wanted search all content of the activedocument foruse strict use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 2; # Throw Errors, I'll catch them my $Word = Win32::OLE->GetActiveObject('Word.Application') || Win32::OLE->new('Word.Application', 'Quit'); foreach $rate($Word->ActiveDocument->Selection->{Text}){ if ($rate =~ /2M/){ print $rate; }}
i want to extract the second line of the activedocument the print it out, but failed$Word->ActiveDocument->Selection->{Text}; $line1 = $Word->Selection->wdline(2)->{Text}; pirnt $line1;
these lines failed.$Word->ActiveDocument->Range($Word->ActiveDocument->text)->Select; my $Str = $Word->Selection->Text; print( "Selection=$Str.\n" );
i am fairly new in perl, i had tried
all failed.foreach $rate($Word->Selection->WholeStory) foreach $rate($Word->Content->Text)
could you please correct me, i know my codes are has problems, but i have no idea about it.
update (broquaint): added formatting
edited: Mon May 12 14:27:16 2003 by jeffa - title change (was: ole word questions)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::OLE word questions
by WhiteBird (Hermit) on May 12, 2003 at 16:21 UTC | |
by rootstock (Novice) on May 13, 2003 at 01:09 UTC | |
|
Re: Win32::OLE word questions
by Zero_Flop (Pilgrim) on May 13, 2003 at 07:07 UTC | |
by rootstock (Novice) on May 13, 2003 at 11:29 UTC |