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

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.

Replies are listed 'Best First'.
Re: Unable to grok Win32::OLE
by NetWallah (Canon) on Apr 08, 2008 at 04:06 UTC
    Take a look at "Win32::ole and MSWord" by Kenny (Obviously, a fellow former COBOL programmer).

    His code demonstrates how to create and format a table in ms word. Your requirements are the reverse of this, but you should be able to glean a lot of information on how to access (set) the attributes, and the names of some important attributes.

         "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom