Parsing a Word File ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pankajit09
    Contributor
    • Dec 2006
    • 296

    Parsing a Word File ?

    How to parse a Word File to retrieve the contents ?
  • Icecrack
    Recognized Expert New Member
    • Sep 2008
    • 174

    #2
    have you tried this yourself ?
    if you have post some code


    and is this microsoft word or is this just a text file?

    Comment

    • nithinpes
      Recognized Expert Contributor
      • Dec 2007
      • 410

      #3
      For parsing MS word file, you can make use of Win32::OLE.
      Last edited by nithinpes; Oct 3 '08, 05:20 AM. Reason: text

      Comment

      • pankajit09
        Contributor
        • Dec 2006
        • 296

        #4
        When I run the below program the MS Word Program also opens. How to avoid that ?



        Code:
        use strict;
        
        use Win32::OLE;
        use Win32::OLE::Enum;
        
        parseAndScanWord($filename);
        
        
        sub parseAndScanWord
        {
            my ($fileName) = @_;
            
            my $document = Win32::OLE -> GetObject($fileName) or return;
            my $paragraphs = $document->Paragraphs();
            my $enumerate = new Win32::OLE::Enum($paragraphs);
            while(defined(my $paragraph = $enumerate->Next()))
            {
                $text = $paragraph->{Range}->{Text};
            }
        }

        Comment

        Working...