Thanks for your responses Greg and Jan.  I've followed your advice and it's 
working beautifully.

Thanks very much!

Chris

----------------------------------------------
Chris Cox
B.IT.(Information Systems) 
Senior Software Engineer

Creatop Interactive Media
Level 1, 240 McCullough Street
Sunnybank. Qld. 4109
Australia
Ph:      1300 85 80 85
Int'l Ph:     +61 7 3216 9755
Mobile: +61 412 416600
http://www.creatop.com.au/
[EMAIL PROTECTED]
----------------------------------------------

----- Original Message ----- 
From: Greg Chapman <[EMAIL PROTECTED]>
To: Jan Dubois <[EMAIL PROTECTED]>
Sent: Friday, May 20, 2005 5:15 PM
Subject: Re: Microsoft Word search and replace issue 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!

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@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to