kanish has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I want to open a doc file and find some thing and replace something. And also add Template.

I know those above works doing Win32::OLE but i am not familiar with that module.

Could you please give link, it would be very help to further.

Thanks a lot!!

Kanishk

Replies are listed 'Best First'.
Re: Open Doc file
by l.frankline (Hermit) on Jan 05, 2006 at 06:26 UTC

    Hi, this can help you...

    use OLE; use Win32::OLE::Const 'Microsoft Word'; my $const = Win32::OLE::Const->Load("Microsoft Word 9.0 Object Library +"); # 9.0 for word2000, 11.0 for word2003 or XP $word=GetObject OLE("Word.Application"); ### To access the active + Word Document $word->Selection->HomeKey ({unit=>$const->{'wdStory'}}); &WordReplaceAll('find', 'replace'); sub WordReplaceAll { my($FindText,$ReplaceText)=@_; for ($word->Selection->Find) { $_->{'Text'} = $FindText; $_->Replacement->{'Text'} = $ReplaceText; $_->Execute ({Replace=>$const->{'wdReplaceAll'}}); } }

    regards,
    Franklin

    Don't put off till tomorrow, what you can do today.