Lets say there are several exactly looking tables in the document and I need data from a specific one of them. I don't know the text inside the table (thats what I'm after) so I can't itererate through all tables and cells and look for the right one. But, I do know exact text before it (it's the name of the section).
How can I select the table I need or figure out which table index (number for ActiveDocument->Tables(#) in the code below)?
use v5.10; use strict; use warnings; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; $Win32::OLE::Warn = 3; # die on errors... my $Word = Win32::OLE->new('Word.Application', 'Quit'); $Word->{'Visible'} = 1; my $document = $Word->Documents->Open('D:\path\tmp.doc'); say "Could not open doc:". Win32::OLE->LastError() if !$document ; say $Word->ActiveDocument->Tables->Count; my $x = $Word->ActiveDocument->Tables(5)->Cell(2,1)->Range->Text; say $x;
In reply to Finding the right table in MS Word document [Win32::OLE] by flamey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |