Here is a general suggestion. When you use the macro recorder, while it very handy to see what sort of code comes up, it is also VERY handy as a starting point for using F1 - Help.
When you got the Selection.Rows.HeadingFormat = wdToggle, if you had put the cursor on HeadingFormat and pressed F1 you would have seen that HeadingFormat has True or False.
As a further hint, whenever you see wdToggle in recorded code, this usually means that you are NOT seeing the actual value. wdToggle does just that. It flips the actual value of the property. It indicates that the property has a True/False value.
For example, here is some recorded code:
Code:
Selection.Font.Bold = wdToggle
Selection.Font.Bold = wdToggle
Is the font Bold, or not?
There is NO way to know, from this code. All you can know is it was flipped one way (whatever that was), then flipped backed.
When you see wdToggle in a recorded macro, this means the property can be True, or False.
HOWEVER, be careful.
You can ONLY manually action, using the menu (Table > Heading Row Repeat), on the first row of a table. Row 1. If the selection is on another row (or the selection does not include Row 1) , Heading row repeat is greyed out.
This is NOT the case using VBA. If the Selection is in Row 3, and you execute:
Code:
Selection.Rows.HeadingFormat = True
then if the table expands onto the next page, the THIRD row of the table exposed on the page will repeat. It will not be a "header row".
VBA allows ANY row (or selected rows) to be repeated.
As real-world situations would rarely (if ever) call for this, I am not sure whether to call this a bug, or a "feature". I am inclined to think the former.
When I am using code to make a table header row repeat, I either error trap (checking to see if the Selection Range includes Row 1), OR avoid using Selection (better anyways) and explicitly use Row 1.
Gerry
My paintings and sculpture