How to Enable/Disable Word Default Menus

  • Thread starter Becky Carter Hickman-Jones
  • Start date
B

Becky Carter Hickman-Jones

Hi again,

I have a custom global template that disables certain menu commands upon
launching Word XP. I would like to reinstate some of those menus, but I
can't find the bit of code in the macros that disables these commands. Would
someone be able to give me an example of how one enables or disables menu
items in VBA? From that, I could search the template and possibly track down
the code I need to change.

Thank you,
Beck
 
C

Charles Kenyon

I would try, instead, disabling the menu commands in your template, either
manually or through code, once. Absent other weird Add-Ins, they will be
disabled when your template is loaded and not disabled when it is not
loaded.

Otherwise, your code would need to be very careful of the customization
context to avoid acting like a virus and permanently changing the interface.

If you would specify which menus/toolbars you are disabling someone here can
probably take a guess at what your code looks like. It will probably have
the term ".enabled = "false"" in it.

If you are hiding the standard or formatting toolbars your code would have
".visible = "false"" in it as well. You would want your exit code to reset
these to what they were when you started your code. These settings could be
saved in variables.

What follows is some code from one of my Add-Ins that changes toolbar
settings.
Word.CommandBars("MyTools MenuBar Chas").Visible = False
Word.CommandBars("MyTools MenuBar Chas").Enabled = False
Word.CommandBars("Formatting Toolbar Holder Chas").Visible = False
Word.CommandBars("Formatting Toolbar Holder Chas").Enabled = False
With CommandBars("Macros")
.Left = 521
.Top = 23
.Height = 28
.Visible = True
.Position = 1
End With
With CommandBars("CDEVTools Kenyon")
.Left = 228
.Top = 23
.Height = 28
.Visible = True
.Position = 1
End With

The first part disables a couple of command bars that are in the template
(they are only used for development, not general work). The sets of With
structures position two of the command bars where I want them.

Hope this helps.
 
B

Becky Carter Hickman-Jones

Thanks Charles. Specifically, the template that I am using disables the
Tools > Macro command. I would like to turn it back on, and I've looked
through the template code to find CommandBars, and I do find a few
instances, but none of them references tools or macro, so I'm at a bit of a
stop.
 
C

Charles Kenyon

Put a (null) macro into your template that intercepts the command. See the
MVP FAQ on vba for details on how to do this.
 

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