views:

1903

answers:

1

I used this vba code in the ThisWorkbook module to disable the right click menu in an Excel workbook.

Private Sub Workbook_Activate()
   With Application.CommandBars.FindControl(ID:=847)
      .Visible = False
   End With
End Sub

Private Sub Workbook_Deactivate()
   With Application.CommandBars.FindControl(ID:=847)
      .Visible = True
   End With
End Sub

Works like a charm.
Problem is, I can't access the right click menu on tabs in ANY workbook now. The second part of the code is supposed to turn it back on, I assumed? Yet it doesn't.

Even when I remove the code entirely, no workbook, not even a new one, has a menu when I click right on one of the tabs.

Is there a general vba codesnippet that "resets" excel maybe? Or a general "enable all menus" thing?

REVISION: This code posted here doesn't disable the rightclick menu, it removes the "delete" option from that specific menu.

A: 

omg

Application.CommandBars("Ply").Enabled = True

-.-
Started googling different keywords after the last edit and BAM.

Skunk
Ok, good for you and us all!Now, mark it as the correct answer, please.
jpinto3912