I have read everything that I could find about win32::OLE to accomplish this task. I am trying to pull table data from a word document and place it in an excel spreadsheet. I have found many examples of adding data to an excel spreadsheet using win32::OLE, so I feel I can accomplish the second task.
I have read the OLE browser info on my windows computer and I installed and looked at Microsofts own oleview.exe information trying to understand how to get table data. Table data in the context that I am using it in means the text and formatting information about the table.
I am able to get table text but my goal is to get all the table information, windows formatting included. I think! Anyway this is what I have.
#!/usr/bin/perl
use warnings;
use strict;
use Win32::OLE;
### File containing tables
my $file = "C:\\DocParse\\test.doc";
### Open for reading
my $word = Win32::OLE->new('Word.Application', 'Quit') or die;
my $readdoc = $word->Documents->Open({FileName=>$file});
my $output = $readdoc->Tables()->Count();
print "There are $output tables.\n";
### read text from the document and print to the console
my $tables = $readdoc->Tables;
foreach my $table (in $tables) {
print $table->Range->{Text};
If there is anyone out there that could at least point me to the correct methods or properties that I should use to get the data that i need.
Thanks Bob
I got 99 problems, but a @%$()_ ain't one.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.