View Single Post
 
Old 03-04-2023, 01:05 PM
bblelli bblelli is offline Windows 10 Office 2021
Novice
 
Join Date: Feb 2023
Posts: 22
bblelli is on a distinguished road
Angry Issue then formatting the tables size

Dears,

I'm facing some troubles when formatting tables using VBA in Microsoft Word.

Basically, I've Word Document with more than 1,000 tables

Each table may have lines with one, four, five, or, six columns.
Each table must have a 15 cm width (no matter the number of columns).

If the table has 6 columns, the distribution of the widths must be:
1st column: 1.4 cm,
2nd column: 1.4 cm,
3rd column: 7.3 cm
4th column: 1.6 cm
5th column: 1.6 cm
6th column: 1.7 cm

If the table has 5 columns, the distribution of the widths must be:
1st column: 1.4 cm,
2nd column: 1.4 cm,
3rd column: 8,9 cm
4th column: 1.6 cm
5th column: 1.7 cm

If the table has 4 columns, the distribution of the widths must be:
1st column: 1.4 cm,
2nd column: 1.4 cm,
3rd column: 10,5 cm
4th column: 1.7 cm

I've been trying to work with the ".setwidth" statement, but it's not working perfectly.

"... .SetWidth ColumnWidth:=CentimetersToPoints(1.71), rulerstyle:=wdAdjustFirstColumn"

Please, check the picture below:
As you can see, the cells are not perfectly aligned.



What's the best way to format tables and make sure that independently of the number of columns they will always be aligned?

Thanks
Attached Images
File Type: png Example.png (10.6 KB, 7 views)
Reply With Quote