Disable the Delete Control in the Edit Menu

G

Guest

I'd appreciate any help with the following. While trying to disable the
"Delete" control on the "Edit" CommandBar, I get an "Run-time error '5':
Invalid call or argument" error. However, the code works for the "Delete
Sheet" Control. Any thoughts on what might be going on??? The macro works
if I substitute "11" as the index, but I'm not confident this will be
universal for all computers the macro might be running on if someone's menu
has been customized. Is this a correct assumption? The code being used is:

Sub Disable_RowDelete()

Application.CommandBars("Row").Enabled = False
Application.CommandBars("Edit").Controls("Delete Sheet").Enabled = False
Application.CommandBars("Edit").Controls("Delete").Enabled = False

End Sub

Sub Enable_RowDelete()

Application.CommandBars("Row").Enabled = True
Application.CommandBars("Edit").Controls("Delete Sheet").Enabled = True
Application.CommandBars("Edit").Controls("Delete").Enabled = True

End Sub
 

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

Similar Threads


Top