In this article I will explain how you can use VBA for word to resize table columns and rows.
Every word document has a Tables collection The first step in working with a table in VBA for word is to determine the table index. Tables in a word document start from the index “1” and go up. So for example the first table would be referenced by using the statement below:
The second table would be reference by using:
and so on . . .
All examples in this article will use the table below as their initial table:
Modify Row Height:
The code below will change the height of the first row of the first table to 50 points:
Tables.Item(1).Rows.Item(1).Height = 50
Modify Column Width:
The code below will change the width of the first column to 20 points:
Tables.Item(1).Columns(2).Width = 20
You can download the file and code related to this article from the link below: