Multiple Button Creation
Hi Todd,
Here you go
Dim newMenu As CommandBarPopup
Dim ctrlPopUp As CommandBarControl
Dim ctrlButton As CommandBarControl
On Error Resume Next
CommandBars("Worksheet Menu Bar").Controls("Import Data").Delete
On Error GoTo 0
Set newMenu = CommandBars("Worksheet Menu Bar").Controls.Add( _
Type:=msoControlPopup, Temporary:=False)
With newMenu
.Caption = "Import Data"
Set ctrlPopUp = .Controls.Add(Type:=msoControlPopup, ID:=1)
With ctrlPopUp
.Caption = "Please Select..."
Set ctrlButton = .Controls.Add(Type:=msoControlButton, ID:=1)
With ctrlButton
.Caption = "Import Data..."
.Style = msoButtonCaption
.OnAction = Application.StartupPath & "\ImportData.xls" &
"!module1.importdata"
End With
Set ctrlButton = .Controls.Add(Type:=msoControlButton, ID:=1)
With ctrlButton
.Caption = "Daily Audits"
.Style = msoButtonCaption
.OnAction = "myMacro1"
End With
Set ctrlButton = .Controls.Add(Type:=msoControlButton, ID:=1)
With ctrlButton
.Caption = "Weekly Renewals"
.Style = msoButtonCaption
.OnAction = "myMacro2"
End With
Set ctrlButton = .Controls.Add(Type:=msoControlButton, ID:=1)
With ctrlButton
.Caption = "Follow-Ups"
.Style = msoButtonCaption
.OnAction = "myMacro3"
End With
End With
End With
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Todd Huttenstine" wrote in message
...
hey guys
I have a code that creates new menu items with different
buttons in them. below is my code:
Set newMenu = CommandBars("Worksheet Menu
Bar").Controls.Add(Type:=msoControlPopup, Temporary:=False)
Dim newMenu As CommandBarPopup
Dim ctrlPopUp As CommandBarControl
Dim ctrlButton As CommandBarControl
newMenu.Caption = "Import Data"
Set ctrlPopUp = newMenu.Controls.Add
(Type:=msoControlPopup, ID:=1)
ctrlPopUp.Caption = "Please Select..."
Set ctrlButton = ctrlPopUp.Controls.Add
(Type:=msoControlButton, ID:=1)
ctrlButton.Caption = "Import Data..."
ctrlButton.Style = msoButtonCaption
ctrlButton.OnAction = Application.StartupPath
& "\ImportData.xls" & "!module1.importdata"
What this code does is Create a new menu item on the
toolbar called "Import Data". When you click it it drops
down and shows 1 new sub-menu with another arrow. This
sub-menu is called "Please Select". Then when you hold
your currsor over the arrow it shows 1 new menu item
called "Import Data...". The code then assigns the button
click (onaction) ImportData.xls" & "!module1.importdata".
So when a user clicks this button it runs the code in
module1.importdata module.
What I would like to do is Create a group of submenus
under the Please Select. So when a user holds his currsor
over Please Select menu arrow, it show him 3 other menu
items with arrows. Lets call the first one "Daily
Audits", the 2nd menu arrow "Weekly Renewals", and then
the 3rd, "Follow-Ups". How do I do this?
Thanks
Todd Huttenstine
|