RE: Microsoft Word search and replace issue
by Jan Dubois other posts by this author
May 19 2005 11:05PM messages near this date
view in the new Beta List Site
RE: Microsoft Word search and replace issue
|
Re: Microsoft Word search and replace issue
On Thu, 19 May 2005, Chris Cox wrote:
> Further on this, I found I had to loop over all the Shapes in the Shapes collection. eg:
>
> use strict;
> use Win32::OLE;
You could try:
use Win32::OLE qw(in);
> use Win32::OLE::Const 'Microsoft Word';
>
> my $word = Win32::OLE->new('Word.Application');
> $word->{visible} = 1;
>
> my $doc = $word->{Documents}->Open("C:\\Word\\Certificate.doc");
and then
foreach my $shape (in $doc-> Shapes) {
$shape-> {TextFrame}->{TextRange}->{Text} =~ s/#tPreferredName#/Chris/g;
}
instead of
> my $count = $doc->Shapes->{Count};
> for (my $i=1; $i < $count; $i++) {
> $doc->Shapes->{$i}->{TextFrame}->{TextRange}->{Text} =~ s/#tPreferredName#/Chris/g;
> }
>
> Surely there's an easier way? If not, it'll have to do!
I'm not sure if it is that much easier. It certainly looks nicer,
but note that I have no idea if it actually works. :)
Cheers,
-Jan
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Chris Cox
Jan Dubois
Greg Chapman
|