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

It turns out all the info I need is in tables. I can do something like:
my $tables = $word->ActiveDocument->{Tables}; for my $table (in $tables) { my $text = $table->ConvertToText(wdSeparateByTabs)->Text; ..... }
The question is: instead of getting the content as a blob of text, can I get it per row and column?

Replies are listed 'Best First'.
Re^5: Reading tables in MS Word
by Corion (Patriarch) on Jul 16, 2025 at 06:08 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.