Protect Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

If I protect my vba code the workbook_Open functions do not work. Neither
does Before_Close() functions. Any ideas?
 
What is the code in your subs? I've never encountered that problem
before.
 
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'this builds the menus that are added when this workbook is loaded
Application.CommandBars("Worksheet Menu Bar").Controls("&Activity").Delete
End Sub

Private Sub Workbook_Open()
Dim Menu1 As CommandBarControl
Dim MainMenuBar As CommandBar
Dim CustomMenu As CommandBarControl
On Error Resume Next

Application.CommandBars("Worksheet Menu Bar").Controls("&Activity").Delete
On Error GoTo 0
Set MainMenuBar = Application.CommandBars("Worksheet Menu Bar")
HelpMenu = MainMenuBar.Controls("Help").Index
Set CustomMenu = MainMenuBar.Controls.Add(Type:=msoControlPopup,
Before:=HelpMenu)
CustomMenu.Caption = "&Activity"
With CustomMenu.Controls.Add(Type:=msoControlButton)
.Caption = "Assign xxxxx"
.OnAction = "CategorizeNewInventory"
End With
'....etc.....
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


Back
Top