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

Hi,

Iam opening the word file through openoffice. My coding is.
use OpenOffice::OODoc;
my $content = odfDocument
(
container => 'c:\in\1.odt',
part => 'content'
);
when i used '1.odt' the vairable shows some value. But when i used '1.doc' the vairable shows <undef>. Any body help me how to open the word file.

Replies are listed 'Best First'.
Re: Opening word file in open office
by afoken (Chancellor) on Jun 27, 2009 at 13:43 UTC

    OpenOffice::OODoc can handle only files in the OpenOffice format. MS Word is a completely different format. OpenOffice::OODoc is not OpenOffice (which can read MS Word documents).

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      Hi,

      If the OpenOffice::OODoc will not read the word files means, any other source to read the word file. Now we are moving to open source.

        There still is no Perl module written to read the various MS Word formats on CPAN, but OLE::Storage has an example script that extracts text from MS Word 6/7/8 files, so OLE::Storage should be able to read MS Word files, but maybe not on that high level that OpenOffice::OODoc offers. The newer OLE::Storage_Lite should also be able to read MS Word files. There is also a module that can WRITE MS Word files (Win32::Word::Writer), but it depends on OLE and an installed MS Word. Newer MS Office versions (starting at Office 2003) write ZIP-compressed XML files for at least Word, Excel, and Powerpoint. You just have to unzip the *.docx file and parse the XML file it contains, very similar to what OpenOffice::OODoc does. See also Re: Excel 2007 Support.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)