Shortcut menus in 2007

X

XP

Using Office 2007 and Win XP;

In XL 2007 shortcut menus (right click menus) is it possible to have a
"Title" row that does nothing when clicked but can be used to group the
custom commands?

For example (hopefully this will show up correctly in the news reader),

Formats <<<title/group
Number
Text
Imports <<<title/group
G/L
Payroll

If this is possible, what is the command to create a "Title" or "Group Name"
line?

Thanks much in advance.
 
R

Ron de Bruin

Something like this maybe

Sub AddToCellDropDown()
Dim CellDropDown As CommandBar
Dim MyDropDownItem As CommandBarControl

Call RemoveFromCellDropDown

Set CellDropDown = Application.CommandBars("Cell")
With CellDropDown.Controls.Add(Type:=msoControlPopup, before:=1)
.Caption = "My menu"
.Tag = "MyDropDownItem"

With .Controls.Add(Type:=msoControlButton)
.Caption = "Copy to new worksheet"
.OnAction = "Copy_Worksheet"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Copy to new workbook"
.OnAction = "Copy_Workbook"
End With
End With
End Sub

Sub RemoveFromCellDropDown()
Dim MyDropDownItem As CommandBarControl
Set MyDropDownItem = Application.CommandBars.FindControl(Tag:="MyDropDownItem")
If Not MyDropDownItem Is Nothing Then
MyDropDownItem.Delete
End If
Set MyDropDownItem = Nothing
End Sub
 

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