Change the availability for a menu item using VBA in Microsoft Wor

C

CaroS

I have a custom menu with about seven macros on it within a specific
template. I only want these macros to be available on the menu if a criteria
is met. In otherwords the macros are "greyed out" and can't be used.

For example.
I have a menu called "Demo" - within it I have various macros "Demo1"
"Demo2" etc. If a bookmark exists within the document called "Demo1" then
"Demo1" is availble on the menu but as the bookmark "Demo2" isn't available
then "Demo2" should be greyed out.

The main problem I have is that on creation the bookmark "demo1" may not
exist, but might exist at a later stage.

Hope this makes sense and that someone can help.

CaroS
 
P

Pete Bennett

That can be done by...

Commandbars ("<whatever bar it's on">).Controls(index).Enabled = False

or

Commandbars ("<whatever bar it's on">).Controls(index).Visible = False

which will hide the option altogether...

You'll need to iterate the controls index to find out what the index of the
control you're interested in is.

You can do this in the immediate window by

?Commandbars("<whatever bar it's on">).Controls(1).Caption (or .OnAction)

And just increment the number until you find the one you want.

Hope that does what you want.

Pete.
 
C

CaroS

Pete

Thanks for steering me in the right direction. I've now got the menu and
the controlbuttons working perfectly.

Thanks again
 

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