Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Unable to grok Win32::OLE

by monk2b (Pilgrim)
on Apr 08, 2008 at 00:59 UTC ( #678869=perlquestion: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://678869]
Approved by ikegami
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2022-05-29 11:59 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (101 votes). Check out past polls.