Re: Microsoft Word search and replace issue
by Greg Chapman other posts by this author
May 20 2005 12:06AM messages near this date
view in the new Beta List Site
RE: Microsoft Word search and replace issue
|
RE: win32::Lanman Error
That is a more efficient way to do it; cycle through the collection.
Good call!
The problem here is that the document contains ActiveX controls and, as
noted, the only way to access ActiveX controls embedded in a document is
to cycle through objects in the z-ordered layers of the document, the
Shapes collection (note that some will have to be searched via the
InlineShapes collection as well). If the document were to contain
traditional Word FormFields, the standard Search/Replace tools would
suffice or, if you prefer to cycle through collections, you would use
the ActiveDocument.FormFields collection.
While ActiveX controls do look better in an online form than do
FormFields, the headaches of printing, anchoring the controls within the
document object, the performance overhead costs, etc., cause most
template designers to stick to traditional form fields within a document
template and to use ActiveX controls only on UserForms (custom dialogs)
where they are much easier to address and have no performance or print
issues. If there's a chance that you are controlling the document's
appearance and the way it works, you'll probably greatly benefit by
going back to FormFields in the doc. Otherwise, I sympathize with you
all!<g>
Greg Chapman
http://www.mousetrax.com
Jan Dubois wrote:
> 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;
> }
>
>
>
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Chris Cox
Jan Dubois
Greg Chapman
|