I have a Perl script which adds rows with some text to an existing table in a Word document using Win32::OLE.
Now, I would like to have it also resize the table's columns to match the text size (just like double-clicking on the vertical line between two columns)
I know how to set a column to a specific width, but I can't seem to find an API for resizing a column to match the text size.
Can anyone tell me what to look for?
For reference, here is a code snippet from my script:
my $tbl = $document->Tables(1);
my $row = $tbl->Rows->Add();
# TODO: resize columns to match the content
Have you tried the Cells.AutoFit() method? e.g.
It seems only supported for Excel 2010 and newer, though.