467,882 Members | 1,249 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,882 developers. It's quick & easy.

Parsing a Word File ?

100+
How to parse a Word File to retrieve the contents ?
Oct 2 '08 #1
  • viewed: 2939
Share:
3 Replies
Icecrack
Expert 100+
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 256MB
For parsing MS word file, you can make use of Win32::OLE.
Oct 3 '08 #3
100+
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.

Similar topics

5 posts views Thread by Rafal 'Raf256' Maj | last post: by
9 posts views Thread by ankitdesai | last post: by
reply views Thread by Uncle Leo | last post: by
3 posts views Thread by aspineux | last post: by
13 posts views Thread by Chris Carlen | last post: by
5 posts views Thread by Luis Zarrabeitia | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.