Excel VBA New Menu

iancook1982

New Member
Joined
Jun 14, 2010
Messages
13
Hi,

I have setup my workbook so that when it opens it adds a menu alongside the File, Edit, View menus at the top. I did this using the below code in the ThisWorkbook code in VBA. With one problem, I get the menu bar called "FoFCIT Divergence Macro", and I get the submenu "Control Panel".

But on clicking this Control Panel option I would like it to launch a userform i have that is called Control_Panel. Is this possible?

Alternatively I have a module that launches this Control_Panel, the module is called "Load_Control.Load_Control"

Code=
Private Sub Workbook_Open()
On Error Resume Next
Dim cmbBar As CommandBar
Dim cmbControl As CommandBarControl
Set cmbBar = Application.CommandBars("Worksheet Menu Bar")
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, temporary:=True)
With cmbControl
.Caption = "&FoFCIT Divergence Macro"
With .Controls.Add(Type:=msoControlButton)
.Caption = "Control Panel"
.TooltipText = "Runs the Control Panel"
.OnAction = "Control_Panel"
End With
End With
Resume Next

End Sub

Can you help? Thanks, Ian.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
It's not a good idea to have a procedure with the same name as the module that contains it. That said you need to change:

.OnAction = "Control_Panel"

to:

.OnAction = "Load_Control"
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,284
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top