Hi everybody;
After adding the reference "Microsoft Visual Basic for Applications Extensibility 5.3" to my project, I created the following ModuleNames procedure, to add the names of the existing sheet and general modules in the active workbook to the right-click of the mouse to be used in VBE window.
The module names are added in the pop-up menu but, the "OnAction" part of the procedure is not working.
According to the lines below, when any of the module names listed in the pop-up menu is clicked, the procedure named "Test" should run and a MsgBox should appear on the screen. But, it's not.
Do you have an idea with that ? Or, my brain is confused ??
Also; if that is possible, how I can return the clicked menu caption ? (Related with the new menus added with the procedure named ModuleNames)
(Running XL9 on Win98)
The related code is below;
Regards,
After adding the reference "Microsoft Visual Basic for Applications Extensibility 5.3" to my project, I created the following ModuleNames procedure, to add the names of the existing sheet and general modules in the active workbook to the right-click of the mouse to be used in VBE window.
The module names are added in the pop-up menu but, the "OnAction" part of the procedure is not working.
According to the lines below, when any of the module names listed in the pop-up menu is clicked, the procedure named "Test" should run and a MsgBox should appear on the screen. But, it's not.
Do you have an idea with that ? Or, my brain is confused ??
Also; if that is possible, how I can return the clicked menu caption ? (Related with the new menus added with the procedure named ModuleNames)
(Running XL9 on Win98)
The related code is below;
Code:
Sub ModuleNames()
Dim cb As CommandBar
Set cb = Application.VBE.CommandBars("Code Window")
With cb
.Reset
For Each ExistingModul In ThisWorkbook.VBProject.VBComponents
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Test"
.FaceId = 36
.Caption = ExistingModul.Name
End With
Set cb = Nothing
Next
End With
End Sub
Sub Test()
MsgBox "Hello !"
End Sub
Sub Auto_Close()
Application.VBE.CommandBars("Code Window").Reset
End Sub
Regards,