Use 'or die Win32::OLE->LastError();' to see what the error is.  In this
case it was 'Type mismatch' on the line with Ecexute.  Then look in the
Visual Basic Object Browser (in Word, under the tools->maco menu is the
Visual Basic Editor, you use this to look at macros that you want to do in
perl, in the VBE under the View menu is the Object Browser).  Here you can
see that 'Const wdReplaceAll = 2'.  So, replace wdReplaceAll with 2.

-- 
Nathaniel G. Bartusiak
TTMS, Keesler AFB


> Greetings to all,
>
> i want to do some 'find and replace' on a .doc file.
> Sample i found on this mailing list was:
>
> -----------------
> use strict;
> use Win32::OLE;
> use Win32::OLE::Const;
>
>
> my $wd = Win32::OLE::Const->Load("Microsoft Word 9.0 Object Library");
> my($outputFile) = 'file.doc';
> my($word) = Win32::OLE -> new('Word.Application', 'Quit');
> $word -> {Visible} = 1;  # Watch what happens
> my($doc) = $word -> Documents -> Open("/perl2exe5.03/wind_spl/ml1.doc");
>  my $search = $doc->Content->Find;
> my $replace = $search->Replacement;
>
> $search->{Text} = "searched";
> $replace->{Text} = "replace";
> $search->Execute({Replace => wdReplaceAll});
>
> $doc -> Close();
> $word -> Quit();
>
> -----------------
>
>
>
> But it does not work: replacement does not happen.
> What is wrong in this code?
> Thanks for any answer.
>
> Philippe Paclet
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to