Forum Discussion
Table Styles and the Ribbon Table Design>Table Option Checkboxes
I was unable to edit the original post. The style name used in the original code should be "Table with Two Conditional Style Elements"
The following shows the VBA steps to solve the scenario of inserting 100 unique tables with the desired style applied and the "desired" styled appearing as defined in the style it the document. Imagine having to this through the UI:
Sub MakeTables()
Dim lngIndex As Long
For lngIndex = 1 To 100
With Selection
'Add the table and apply the style
ActiveDocument.Tables.Add .Range, 2 + lngIndex, 7
.Tables(1).Style = "Table with Two Condtional Style Elements"
'The following six steps replicates the tedious and ridiculous process of _
selecting the table, select Table Design tab and setting the associated _
Table Style Option checkboxes to match the actual table conditional formatting.
.Tables(1).ApplyStyleHeadingRows = True
.Tables(1).ApplyStyleLastRow = True
.Tables(1).ApplyStyleFirstColumn = False
.Tables(1).ApplyStyleLastColumn = False
.Tables(1).ApplyStyleRowBands = False
.Tables(1).ApplyStyleColumnBands = False
'Prepare to insert next table
.Tables(1).Range.Select
.Collapse Direction:=wdCollapseEnd
.InsertBefore vbCr
.MoveDown Unit:=wdParagraph, Count:=1
End With
Next lngIndex
lbl_Exit:
Exit Sub
End SubI think the behavior of the Table Style Option checkboxes is the utterly stupid. Showing checkboxes checked with a table that has no associated formatting is not only pointless, it is confusing. Knowing nothing about the bizarre behavior of these button, a user might expect something to change if a checked box is unchecked and certainly would miss any emphasis intended when formatting is defined i.e., Total Row but the box is not checked.
A more sensible behavior would be only boxes with associated conditional formatting defined is enabled and checked by default. If a user does not want to see style defined emphasis let them turn if off after the table is inserted and the style is applied. Not the other was around.