Tools For Office - Excel Menus

T

Troy

Using Tools for Office, does anyone know how to create
Cascading menus (menus within menus) for Excel?

Also does anyone know how to create right-
click/context/short-cut menus (if it is possible) for
Excel?

Thanks.
 
C

Chip Pearson

Troy,

Are you talking about the Visual Studio Tools For Office? You
create menu items there in very much the same way as you do in
VBA. For example,

Friend MenuCtrl As Office.CommandBarControl ' this goes on the
Tools menu

Private WithEvents MenuItem1 As Office.CommandBarButton 'this
goes under the control

Private WithEvents MenuItem2 As Office.CommandBarButton 'this
goes under the control


Try
MenuCtrl =
Me.ThisApplication.CommandBars.FindControl(ID:=cTOOLS_MENU).Contr
ols.Add _
(Type:=Office.MsoControlType.msoControlPopup,
temporary:=True)
MenuCtrl.Tag = cMENU_TAG
MenuCtrl.Caption = "Office NET Tools"

MenuItem1 = MenuCtrl.Controls.Add()
MenuItem1.Caption = "1. Show Modal Form"
MenuItem1.Tag = cMENU_TAG

MenuItem2 = MenuCtrl.Controls.Add()
MenuItem2.Caption = "2. Show Modeless Form"
MenuItem2.Tag = cMENU_TAG
Catch ex As Exception
MessageBox.Show ("Error creating menu items: " & vbCrLf & _
ex.Message)
End Try



You can custom the right-click menu by adding controls to the
"Cell" menu.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Guest

Thanks. Excuse my ignorance, but how do you add the items
to the "cell" menu (ie how do you get a handle on
the "Cell" menu)

Thanks again.
 
C

Chip Pearson

Troy,

Use
Dim CmdBar As Office.CommandBar
CmdBar = Me.ThisApplication.CommandBars("Cell")

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
S

Shetty

You can custom the right-click menu by adding controls to the
"Cell" menu.

I have created the control on the right-click menu which runs a macro
for the selected cells. But this control is not available (control
button fades up) when entire raws or column is selected. Code is as
below.

Sub My_Format()

CommandBars("Cell").Reset

With CommandBars("Cell")
With .Controls.Add
.FaceId = 20
.Caption = "My Format"
.OnAction = "form"
End With
End With

End Sub

Thanks,
Shetty
 
Top