Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: Reading tables in MS Word

by Corion (Patriarch)
on Jul 16, 2025 at 06:08 UTC ( [id://11165660]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Reading tables in MS Word
in thread Reading tables in MS Word

Again, from the Microsoft documentation on the MS Word Table Object, look at the ->Cell method. With that, you can get the content of a table by row and column.

Replies are listed 'Best First'.
Re^6: Reading tables in MS Word
by spiral (Novice) on Jul 16, 2025 at 15:20 UTC
    Never used VB, so I must be doing something wrong:
    for my $table (in $tables) { my $rownum=1;#VB starts at 1, not 0 while($rownum<=$table->Rows->Count){# the documentation #(rather sketchy) talks about Table.Column.Count #Probably the mistake is here my $cell1=$table->Cell($rownum,1); # get the cell of row $rownum and 1st column my $text1=$cell1->ConvertToText(wdSeparateByTabs)->Text; print "$text1\n"; $rownum++; } }

      In what way does your snippet not work? If you don't tell me, I can't really help you there.

      Pressing ALT+F11 in Word opens up the VBA "IDE", and then pressing CTRL+G gives you a console where you can enter VBA commands to try them out.

      That could help you narrow down where your Perl code goes wrong.

        for my $table (in $tables) { my $rownum=1; while($rownum<=$table->Rows->Count){ print "calling cell1\n"; my $cell1=$table->Cell($rownum,1); print "cell1-$cell1 calling text\n"; # prints cell1-Win32::OLE=HASH(0x1c7fbc32b50) calling text my $text1=$cell1->ConvertToText(wdSeparateByTabs)->Text; #This is where it fails with the message #Win32::OLE(0.1713) error 0x80020011: "Does not support a collection" # in METHOD/PROPERTYGET "" print "after text1cell1 = $text1\n"; $rownum++;} }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11165660]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2026-04-15 16:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.