Ok, so I have created a custom submenu in Excel that uses the "SheetBeforeRightClick" event in the "ThisWorkbook" object to initialize. In the custom submenu, I want to use one of the choices to load a form that I have created. I am trying to do this directly when selecting the submenu entry, by using "MyForm.Show", but this doesn't work. As a workaround I use an intermediary subroutine, "Sub Load_MyForm" where I put the same command, and then it works! Anyone who knows how to load the form directly from the submenu click event without going through an intermediary subroutine? Thanks!
The workaround (which works) in "ThisWorkbook":
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
...
With cbpop.Controls.Add(Type:=msoControlButton)
.Caption = "Open MyForm"
.OnAction = "ThisWorkbook.Load_MyForm"
End With
....
Sub Load_MyForm()
MyForm.Show
End Sub
Ideally, I want to do something like:
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
...
With cbpop.Controls.Add(Type:=msoControlButton)
.Caption = "Open MyForm"
.OnAction = "MyForm.Show"
End With
....
but can't get this to work! 
Any ideas please?
Bookmarks