Can't Disable the "Insert - Rows" menu option in Excel using VBA m

G

Guest

I have a macro for which I do some conditional checks in the SelectionChange
event for a worksheet.

When one of my conditions evaluates to true I'm trying to do the following:
*) Disable the Insert - Rows menu option (from the main menu bar at the top
of Excel)


I have tried many different things. The closest I can get is to disable the
"Insert" control entirely (which is not acceptable). I only want to disable
the "Insert Rows" option.

The following code disables the entire "Insert" control on the Worksheet
Menu Bar:
Application.CommandBars("Worksheet Menu Bar").Controls("Insert").Enabled =
False

I CAN'T figure out how to disable the Rows option underneath the Insert
control though!! Any help would be greatly appreciated.

Thanks
 
G

Guest

YOU ARE A LIFESAVER!!! Thank you so much. That is exactly what I want.

Do you have a list of the control id's (like 296 in this example)??

I may need to do this for other sub-menu items.

Thanks again!
 
D

Dave Peterson

Hit alt-f11 to get to the VBE
hit ctrl-g to get to the immediate window
type this in and hit enter:
?Application.CommandBars("worksheet menu bar").Controls("Insert") _
.Controls("columns").ID

I get 297 back.
 
G

Guest

Thanks, perfect.
--
PK9


Dave Peterson said:
Hit alt-f11 to get to the VBE
hit ctrl-g to get to the immediate window
type this in and hit enter:
?Application.CommandBars("worksheet menu bar").Controls("Insert") _
.Controls("columns").ID

I get 297 back.
 

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