I have bunch of Microsoft Word开发者_高级运维 documents, and want to find and replace a word, e.g.
find the word banana replace it with apple
You could use Win32::OLE.
It seems that your interaction would look about like this (completely untested):
use Win32::OLE;
my $word = Win32::OLE->new('Word.Application') or die "Could not find Word.\n";
my $doc = $word->Documents->Open($filename);
my $content = valof $doc->{Content};
$content =~ s/banana/apple/g;
$doc->{Content} = $content;
$doc->Save();
$doc->Close();
$word->Quit();
Read the Win32::OLE documentation in conjunction with the VB documents for better/further information.
You might also find the tool "Multireplace" at the bottom of this page interesting.
精彩评论