I use VBA to recreate my right click menu on a work book created in 2019.
At the time I used this piece of code to reset the menu when I swapped between books and another similar when i swapped back
Am I right in saying this is no longer required? it seems each new book has a completely independent menu
Not sure what is going on.
It seems the windowdeactivate is required so I can swap to a different book, but I have completely removed this code and it still works....
But I don't understand why.
At the time I used this piece of code to reset the menu when I swapped between books and another similar when i swapped back
VBA Code:
Private Sub Workbook_WindowDeactivate(ByVal Wn As Window)
'resets right click menu when worksheet is not in focus
Application.CommandBars("Cell").Reset
End Sub
Am I right in saying this is no longer required? it seems each new book has a completely independent menu
Not sure what is going on.
It seems the windowdeactivate is required so I can swap to a different book, but I have completely removed this code and it still works....
But I don't understand why.
VBA Code:
Private Sub Workbook_WindowActivate(ByVal Wn As Window)
'Sets right click menu when worksheet comes into focus
Application.Calculation = xlCalculationAutomatic
Application.CommandBars("Cell").Reset
For Each Item In Application.CommandBars("Cell").Controls
Item.Delete
Next Item
With Application.CommandBars("Cell").Controls.Add(Temporary:=True)
.Caption = "Main Update"
.Style = msoButtonCaption
.OnAction = "Main_Update"
End With
With Application.CommandBars("Cell").Controls.Add(Temporary:=True)
.BeginGroup = True
.Caption = "Expedite"
.Style = msoButtonCaption
.OnAction = "expedite_report"
End With
'...Lots more repeated....
End Sub
Last edited: