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
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to