Hi,
I hope everyone is well.
I am looking for some advice from the VBA experts.
I apologize if this has a complete solution elsewhere I have not been able to find it.
I have word documents that will contain a number of tables.
Each table may contain up to 15 columns.
If a table contains less columns I can delete a column from the final code.
I would like to format them in a specific way
Columns 1,2,4,6,7,9,10,12
· Font Size 2
· Font Color White
· Border Color White
· Column Width = 20px
Columns 2,5,8,11
· Font Size 12
· Font Color - Black
· Border Color Dark Grey
· Column Width = 150px
I know that I could run 2 separate macros – I would end up with a long page of code for each column.
However, I would like to learn how to do it in one - as I have a lot of documents to convert.
I have tried to fiddle about and searched online documentation but am not closer to a solution.
My attempt at putting together the concept,
Column Sizes
Code:
For Each Table In ActiveDocument.Tables
On Error Resume Next
Table.Columns(1).Width = 20
Table.Columns(2).Width = 20
Table.Columns(4).Width = 20
Table.Columns(6).Width = 20
etc
On Error GoTo 0
Next
End Sub
Formatting the Columns
Code:
Dim Table As Table, Cell As Cell
Dim col as column
For Each Table In ActiveDocument.Tables
For Each Cell In Table.Range.Cells
For Each Cell In .Columns(1).Cells
Cell.Width = 20px
Cell.Range.Font.Name = "Arial"
Cell.Range.Font.Size = 2
Cell.Range.Font.ColorIndex = white
Cell.border.color =white
Next Cell or column
Next Table
End Sub
I have managed to confuse myself

- and am making errors. Also they are separate macros - I'm not sure how to combine them.
I would appreciate some help.
To Recap.
I need to Format all the Tables in a document, that have various number of columns.
Columns 1,2,4,6,7,9,10,12
· Font Size 2
· Font Color White
· Border Color White
· Column Width = 20px
These columns have ids and codes in them hence trying to give them a hidden appearance.
Columns 2,5,8,11 - Normal Columns
· Font Size 12
· Font Color - Black
· Border Color Dark Grey
· Column Width = 150px
I would be really grateful if an expert can guide me.
Thanking you in advance for your kind help and time.
J