W
Wendy
I'm converting some old Word 97 macros to Word 2002. In Word97 I had a
macro called 'TableInsertGeneral' and was therefore able to 'hijack'
the Insert Table menu option so that it ran my code instead and
formatted the tables correctly everytime.
Unfortunately the same macro name does not appear to work in 2002. Can
anyone advise what macro is now used as the equivalent of going to the
Table menu, choosing Insert, then Table. I only need to do this
because the Table Styles won't let me setup exactly what I need! I've
posted my code below, just in case it helps.
Thanks.
Sub TableInsertGeneral()
Dim objRow As Object
'display Word's own dialog so that user can select no. of cols/rows
With Dialogs(wdDialogTableInsertTable)
.Display
.Execute
End With
With Selection.Tables(1)
.Style = "Table_AMPCI"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
'override table style & change text style for all rows
For Each objRow In .Rows
objRow.Range.Style = "Table body"
Next objRow
.Rows(1).Range.Style = "Table heading"
'remove border as table style doesn't seem to allow removal!!
.Rows(2).Borders(wdBorderTop).LineStyle = wdLineStyleNone
End With
End Sub
macro called 'TableInsertGeneral' and was therefore able to 'hijack'
the Insert Table menu option so that it ran my code instead and
formatted the tables correctly everytime.
Unfortunately the same macro name does not appear to work in 2002. Can
anyone advise what macro is now used as the equivalent of going to the
Table menu, choosing Insert, then Table. I only need to do this
because the Table Styles won't let me setup exactly what I need! I've
posted my code below, just in case it helps.
Thanks.
Sub TableInsertGeneral()
Dim objRow As Object
'display Word's own dialog so that user can select no. of cols/rows
With Dialogs(wdDialogTableInsertTable)
.Display
.Execute
End With
With Selection.Tables(1)
.Style = "Table_AMPCI"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = True
'override table style & change text style for all rows
For Each objRow In .Rows
objRow.Range.Style = "Table body"
Next objRow
.Rows(1).Range.Style = "Table heading"
'remove border as table style doesn't seem to allow removal!!
.Rows(2).Borders(wdBorderTop).LineStyle = wdLineStyleNone
End With
End Sub