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

Hi,

Currently Iam using "use Win32::OLE;" to open the word file and catching the styled text and paste the text in another word file.

But now iam pushed to move to Openoffice due to open source.

My coding is:

$wd->Documents->Open
({FileName=>"${iFile}",ConfirmConversions=>0,AddToRecentFiles=>0}) || die "Can't open the file... ${iPath}.${ifile}";
$wd->Selection->HomeKey(wdStory);
$wd->Selection->Find->{'Style'}='Keywords';
while ($wd->Selection->Find->Execute) {
$wd->Selection->Copy;
$wd->Documents("${path}Out.doc")->Activate;
$wd->Selection->MoveRight;
$wd->Selection->Paste;
$wd->Documents("${iFile}")->Activate;
$wd->Selection->MoveRight;
$flag++;
}
I don't know how to do this using open office.

Any body know what module shall i use to do this.

Thank in advance.
Regards, Mythili B

Replies are listed 'Best First'.
Re: About open office
by Corion (Patriarch) on Jun 16, 2009 at 15:49 UTC

    You'll have to rewrite your code to use OpenOffice. Potentially, using OpenOffice::UNO. But as OpenOffice does not support Windows OLE automation, you can throw away all your code using Win32::OLE. Complain to whoever mandated the move away from Microsoft Office.

Re: About open office
by CountZero (Bishop) on Jun 16, 2009 at 18:07 UTC
    OpenOffice::OODoc seems like a good bet to have a look at. It is a whole family of modules to deal directly with OpenOffice files. OpenOffice::OODoc::Text specifically deals with the wordprocessor files (or rather the "text-containers" which you can also find in spreadsheets of the OpenOffice suite).

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      Hi,
      I tried the above module to open the word file through openoffice through perl. But i can't. Would you please help me in this.

      Waiting for your reply. Thanks,

        I guess the first step would be that you show us the relevant part of the code you have written, and describe what it should do and how it fails for you.