I am just starting to use Perl and I want to open and search the
contents of word documents that contain macros, but when my Perl script
opens the Word documents Word invokes a dialog box that asks if I want
to enable or disable the macros in the document. I do not need the
macros to be running when I search the document.How can I open the
documents without the dialog box opening for each document?
The code I have used to call my sub routine is:

$rv=&readfile($Directory,$file,$SearchPattern);

And the sub routine is:

sub readfile{
my
($FileName,$SearchPattern,$word,$paragraphs,$paragraph,$enumerate,$style
,$text,$document);
$word = CreateObject Win32::OLE 'Word.Application' or die $!;
$word -> {DisplayAlerts}        = 0;
$word->{Visible} = 0;
$document=Win32::OLE -> GetObject("$_[0]$_[1]");

$SearchPattern = "$_[2]";

$paragraphs = $document->Paragraphs();
$enumerate = new Win32::OLE::Enum($paragraphs);
while(defined($paragraph = $enumerate->Next())) {
    $text = $paragraph->{Range}->{Text};
    if($text=~/$SearchPattern/){
        print STDOUT "Search Text found : $_[1]";
        return;
    }
}
$document -> Close();
$word -> Quit();

}

Thanks for your help

Mike Harris

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to