View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default Drop Down Menu on tool bar

In case you were looking for a programmatic way I append the following
example code. Note that if others are using your program, if they do a "Save
As..." then the menu items will be reassigned to the macros in the new wb
instead (i.e. will point to the macros in the new wb). Running the macros
from the original will cause the new wb to open or will raise an error if it
cannot be found. This can be a real pain.

To avoid the above, I suggest that you use the wb_open event to call the
MakeMenu macro and recreate the menu each time. This will always ensure that
the macros assignments point to your wb. The menu is made Temporary so that
it is destroyed each time the wb is closed.


Sub MakeMenu()
Dim i As Integer
Dim arr1 As Variant, arr2 As Variant, arr3 As Variant

arr1 = Array("Macro1", "Macro2", "Macro3", "Macro4", "Macro5")
arr2 = Array("Caption1", "Caption2", "Caption3", "Caption4", "Caption5")
arr3 = Array(132, 133, 134, 135, 136)
With Application.CommandBars(1).Controls.Add(msoControl Popup, Temporary:=True)
.Caption = "&My macro list"
.TooltipText = "Select a macro from the list"
For i = 0 To 4
With .Controls.Add
.OnAction = arr1(i)
.Caption = arr2(i)
.FaceId = arr3(i)
End With
Next
End With
End Sub

Regards,
Greg