Reputation: 5297
I have a basic TableStyle laid out as follows:
Sub NewTableStyle()
Dim StyTbl As Style
Set StyTbl = ActiveDocument.Styles.Add(Name:="PhaseTable", Type:=wdStyleTypeTable)
With StyTbl.Table
.Alignment = wdAlignRowLeft
With .Condition(wdFirstRow)
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.Visible = True
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.Visible = True
.LineWidth = wdLineWidth150pt
End With
End With
End With
End Sub
But I want to expand on it, applying the following to all cells:
...and the following to the first row only:
I think I can add something like:
With StyTbl.Font
.Size = 12
.Name = "Times New Roman"
End With
To the end of my subroutine to apply the following properties to the entire table. However, I can't seem to figure out the selective first row bolding or the vertical alignment.
I know it is probably possible as I can modify the Excel default styles to have these options in the GUI. How do I set those options in the VBA Style
which I plan to apply to tables?
Upvotes: 0
Views: 1687
Reputation: 3188
You can access the .Font
of the .Condition(wdFirstRow)
to set the different settings you need:
Sub NewTableStyle()
Dim StyTbl As Style
Set StyTbl = ActiveDocument.Styles.Add(Name:="PhaseTable", Type:=wdStyleTypeTable)
With StyTbl.Table
.Alignment = wdAlignRowLeft
With .Condition(wdFirstRow)
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.Visible = True
.LineWidth = wdLineWidth150pt
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.Visible = True
.LineWidth = wdLineWidth150pt
End With
With .Font
.Bold = False
.Size = 12
.Name = "Times New Roman"
End With
End With
End With
End Sub
But there don't seems to have vba access to vertical alignment.
Upvotes: 2