How to stop users create nested tables? Possible

K

Ken Wan

Hi,
The organization I worked for would like stop users create nested tables.
Can this be done with VBA code? Any suggestions will be greatly appreciated.
Ken
 
T

Tony Strazzeri

Hi Ken,

You need to create a macro with the same name as the insert table
function "not sure of the exact name).

in that macro you can use selection.information to determine if the
cursor is in a table. If it is display a message and quit. If it
isn't then you can go on and execute the insert table dialog.

Cheers
TonyS.
 
C

Cindy Meister -WordMVP-

Hi Tony,
You need to create a macro with the same name as the insert table
function "not sure of the exact name).
Have you found any way to intercept the toolbar button? I've never
been able to catch that with an InsertTable macro...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jan 24
2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
M

martinique

Most of the built-in Word commands are the same as the
menu_name+menu_caption: in this case TableInsertTable. (And in this case, a
macro of that name will trap the toolbar button also)

You can see the full list of Word commands by going to Tools > Macros and
selecting Word Commands from the Macros In drop-down.

May I ask WHY you want to prevent nested tables? I know of one organization
doing the opposite: trying to encourage them as an alternative to merged and
split cells, because it simplifies processing for HTML conversion.
 
K

Ken Wan

Hi, Martinique,
Thanks for you help. The reason for preventing users to use nested tables is
that we need to convert the word documents into messages of some fairly old
messaging standard. These messages do not support complicated tables.
Regards,
Ken
 
M

martinique

Fair enough. Watch for merged and split cells. They're a bugger to deal with
also.
 
T

Tony Strazzeri

Good point Cindy,

I was only working off theory. I hadn't realised that this little
beastie was different.

I guess you could replace the toolbar button with one pointing to the
macro, as another respondent suggested, but I am sure you probably
already know this.

I will now indulge in a little S&M <g>

Cheers
TonyS.
 
T

Tony Strazzeri

As Martinique pointed out, the macro name to use is
TableInsertTable.

When I looked at the Word Command list, TableInsertTable
does not appear. What appears is InsertTableGeneral. But
when I select InsertTableGeneral, the Run button stays
greyed out.

If I assign a shortcut key to InsertTableGeneral it will
run and if I have a macro by the same name that will run
instead.

Curiously, TableInsertTable has a wdDialog constant for
use with the dialogs collection.

I initially looked at what was being run by the Insert
table menu without success. I compared its settings with
that of Format Paragraph (which also launches a dialog
box). I couldn't see any significant difference.
Curiously neither had a "onAction" setting. So I simply
set the onAction for the table menu using
Dim ctl As CommandBarButton
Set ctl = Application.CommandBars("Menu Bar").Controls
("T&able").Controls("&Insert").Controls("&Table...")
ctl.OnAction = "TableInsertGeneral"

Cheers
TonyS.
 

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