Menu add-in
On 18 Jun, 11:59, Peter wrote:
Dear all brains,
I have already written an add-in that creates a menu called "Zenos"
however I am having some serious trouble adding menu items to that
menu by another add-in.
This is the code, if anyone has any ideas please let me know:
Dim tns As Object
Set tns = CommandBars("Worksheet Menu Bar").Controls("Zenos")
With tns
.Controls.Add(Type:=msoControlButton).Caption = "Daily Payments
Monitoring"
.Controls("Daily Payments Monitoring").OnAction = "TNS_report"
End With
Thanks,
Peter
Don't worry trying to work this out, here is the answer:
Sub menuItem_Create()
With CommandBars("Worksheet menu bar").Controls("Zenos")
.Controls.Add(Type:=msoControlButton).Caption = "Peter"
.Controls("Peter").OnAction = "peter"
.Controls("Peter").FaceId = 285
End With
End Sub
Sub peter()
MsgBox "Peter"
End Sub
Sub delete_peter()
Dim myCmd As Object
Set myCmd = CommandBars("Worksheet menu bar").Controls("Zenos")
myCmd.Controls("Peter").Delete
End Sub
|