use Win32::OLE; use Win32::OLE::Enum; print "Name of Word document: ";# input the document name along with t +he location chomp ($doc = <STDIN>); # This is to create document object $document = Win32::OLE -> GetObject("$doc"); #steps used to convert the Word document in to a text file. print "Name of upload file: "; chomp ($upload = <STDIN>) ; open (FH,">$upload"); print "Extracting Text ...$document \n"; $paragraphs = $document->Paragraphs(); $enumerate = new Win32::OLE::Enum($paragraphs); while(defined($paragraph = $enumerate->Next())) { # $style = $paragraph->{Style}->{NameLocal}; # print FH "+$style\n"; $text = $paragraph->{Range}->{Text}; $text =~ s/[\n\r]//g; $text =~ s/\x0b/\n/g; print FH "=$text\n"; } # Steps used to parse the text file and get the required information i +n comma seperated values open (FH,"<$upload"); while (<FH>) { chomp; if (m/Test Script Name/) { $test_case_name = <FH>; chomp $test_case_name; $test_case_name =~ s/\=//; } if (m/Script Description/) { $short_desc = <FH>; chomp $short_desc; $short_desc =~ s/\=//; print "$test_case_name,$short_desc\n"; } } close FH;
20080119 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
In reply to Re^4: Extracting information from a MS WORD Document
by Saran2
in thread Extracting information from a MS WORD Document
by Saran2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |