Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Parsing MSWord File

by pankaj_it09 (Scribe)
on Oct 02, 2008 at 12:29 UTC ( [id://714991]=perlquestion: print w/replies, xml ) Need Help??

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

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

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}; } }

Replies are listed 'Best First'.
Re: Parsing MSWord File
by Corion (Patriarch) on Oct 02, 2008 at 12:41 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Parsing MSWord File
by jplindstrom (Monsignor) on Oct 02, 2008 at 13:30 UTC
    On a general note, keep the task manager open and look for MS Word processes not being terminated properly if your script is Ctr-C:ed, or exit()-ed without the Win32::OLE object being destroyed.

    That may also be the reason if you have problems opening/saving Word documents for no reason -- there is another process still alive with the document open.

    /J

      I did like this but no effect :-

      my $document = Win32::OLE -> GetObject($doc,sub {$_[0]->Quit;});
Re: Parsing MSWord File
by GrandFather (Saint) on Oct 06, 2008 at 23:56 UTC
    $document->{Visible} = 0;

    How can you write the sample code you gave, yet not understand how to set a property on an object nor understand what False is?


    Perl reduces RSI - it saves typing
      The code is downloaded.

        This is not how programming works, at least not here. We expect you to do your own work, to do your own research and to learn the language instead of asking us all the time to do your work for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://714991]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-29 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found