Disabling and Enabling Specific Menu Items via VBA

actjfc

Active Member
Joined
Jun 28, 2003
Messages
416
Excel Friends,

I got this code to disable/enable Right Click on the Sheet Tab:

Code:
Private Sub Workbook_Activate()
   Application.CommandBars("Ply").Enabled = False
End Sub
 
Private Sub Workbook_Deactivate()
    Application.CommandBars("Ply").Enabled = True
End Sub

It worked fine, but I got out of excel totally, and it is still Disabled in all my workbooks. Enabling it is driving me crazy!

I also need hot to disable and enable Delete Sheet and Hide/Unhide sheets, in the menu, not just the Right Click.

Can somebody help!

Thanks!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
if you created a copy of
Code:
Private Sub Workbook_Deactivate()
    Application.CommandBars("Ply").Enabled = True
End Sub

to

Code:
Sub test()
    Application.CommandBars("Ply").Enabled = True
End Sub

and run as normal
 
Upvote 0
It was easy! thanks! But why is not working the Sub Workbook_Deactivate?

Can somebody help me with the disabling and enabling Delete Sheet and Hide/Unhide sheets, in the menu? not just the Right Click.

Thanks!
 
Upvote 0
would think workbook_close, would be better, deactivate might work in switching around.

not sure about your other problems, it will be on the web somewhere

If you do get answers, post them back to the thread for others
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,753
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top