Adding a divider to an add-in using vba in excel 2007

T

test_52

I have done some research and thought that I had this figured out, but it is
not giving me the result that I am looking for. I am trying to add a divider
to a drop down list between different macros. I thought this was done by the
BeginGroup property, but it is not adding the divider. I have posted a
section of my code below. Can anyone tell me if I am going about this wrong?
Any help would be great. Thanks, Jason



Set cmdBar = Application.CommandBars("Worksheet Menu Bar")
Set cmdBarMenu = cmdBar.Controls.Add(Type:=msoControlPopup,
temporary:=True)
With cmdBarMenu
.Caption = "Tools"
.Tag = "JJT"
End With

Set cmdBarMenuItem = cmdBarMenu.Controls.Add(Type:=msoControlButton)
With cmdBarMenuItem
.Caption = "Merge"
.OnAction = "MergeCells"
.Tag = "JJT"
.FaceId = 798
End With

cmdBarMenu.BeginGroup = True

Set cmdBarMenuItem = cmdBarMenu.Controls.Add
With cmdBarMenuItem
.Caption = "Unmerge"
.OnAction = "UnmergeCells"
.Tag = "JJT"
.FaceId = 800
End With
 
J

Jim Cone

See the two <<< notations below...
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"test_52" <[email protected]>
wrote in message
I have done some research and thought that I had this figured out, but it is
not giving me the result that I am looking for. I am trying to add a divider
to a drop down list between different macros. I thought this was done by the
BeginGroup property, but it is not adding the divider. I have posted a
section of my code below. Can anyone tell me if I am going about this wrong?
Any help would be great. Thanks, Jason

Set cmdBar = Application.CommandBars("Worksheet Menu Bar")
Set cmdBarMenu = cmdBar.Controls.Add(Type:=msoControlPopup,
temporary:=True)
With cmdBarMenu
.Caption = "Tools"
.Tag = "JJT"
End With
Set cmdBarMenuItem = cmdBarMenu.Controls.Add(Type:=msoControlButton)
With cmdBarMenuItem
.Caption = "Merge"
.OnAction = "MergeCells"
.Tag = "JJT"
.FaceId = 798
End With

'cmdBarMenu.BeginGroup = True '<<<< Not this

Set cmdBarMenuItem = cmdBarMenu.Controls.Add
With cmdBarMenuItem
.Caption = "Unmerge"
.OnAction = "UnmergeCells"
.Tag = "JJT"
.FaceId = 800
.BeginGroup = True '<<<< Do this instead
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top