By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,710 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,710 IT Pros & Developers. It's quick & easy.

Parsing a Word File ?

100+
P: 296
How to parse a Word File to retrieve the contents ?
Oct 2 '08 #1
Share this Question
Share on Google+
3 Replies


Icecrack
Expert 100+
P: 174
have you tried this yourself ?
if you have post some code


and is this microsoft word or is this just a text file?
Oct 2 '08 #2

nithinpes
Expert 100+
P: 410
For parsing MS word file, you can make use of Win32::OLE.
Oct 3 '08 #3

100+
P: 296
When I run the below program the MS Word Program also opens. How to avoid that ?



Expand|Select|Wrap|Line Numbers
  1. use strict;
  2.  
  3. use Win32::OLE;
  4. use Win32::OLE::Enum;
  5.  
  6. parseAndScanWord($filename);
  7.  
  8.  
  9. sub parseAndScanWord
  10. {
  11.     my ($fileName) = @_;
  12.  
  13.     my $document = Win32::OLE -> GetObject($fileName) or return;
  14.     my $paragraphs = $document->Paragraphs();
  15.     my $enumerate = new Win32::OLE::Enum($paragraphs);
  16.     while(defined(my $paragraph = $enumerate->Next()))
  17.     {
  18.         $text = $paragraph->{Range}->{Text};
  19.     }
  20. }
Oct 6 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.