Default 'Insert Table' macro for Word 2002

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
 
D

Doug Robbins - Word MVP

TableInsertGeneral will hijaak the insertion of a table from the table icon
on the toolbar, but not from the menu as you have discovered. Maybe you
will have to remove the Insert Table item from the Table menu to force the
user to use the icon on the toolbar.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
W

Wendy

Hi Doug

Thank you so much. This has been driving me nuts for the last few days
and the answer is so simple and obvious really but it never even
occured to me to approach it from this angle!!

Wendy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top