Search and replace in msword .doc
by Philippe Paclet other posts by this author
Jan 28 2003 5:17PM messages near this date
view in the new Beta List Site
sprintf formating float question
|
Re: Search and replace in msword .doc
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
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Philippe Paclet
|