How do I write the macro line to "Right-Mouse-Click" ?

J

Jezebel

You don't. You call directly whatever function is triggered by the
right-click. If you're trying to show a context menu, use

CommandBars("MenuName").ShowPopup
 
C

Cheryl1325

So what would I place as the name of the menu I get when I Right-Clik on an
e-mail?
 
J

Jezebel

Not sure which menu you're referring to. Explore the list:

Dim pBar As Office.CommandBar

For Each pBar In CommandBars
Debug.Print pBar.Name
Next
 
K

Klaus Linke

When working with context menus, I've used the macros below to show the name
of the context menu *in* the context menu.
Use at your own risk... The macros mess with your context menus, and aren't
that well tested.
If in doubt, don't save Normal.dot after you have run the macro... That way,
any changes will not be permanent.

Klaus


Sub ContextMenusShowName()
' run to show the name of the context menu
' in the context menu (for all context menus)
Dim myCB As CommandBar
Dim myCBB As CommandBarButton
On Error Resume Next
For Each myCB In CommandBars
If myCB.Type = msoBarTypePopup Then
Debug.Print myCB.Name, myCB.Type
Set myCBB = myCB.Controls.Add(Type:=msoControlButton, Before:=1)
With myCBB
.Caption = "context menu: " & myCB.Name
.Tag = "ContextMenusShowName"
End With
End If
Next myCB
End Sub

Sub ContextMenusRemoveName()
' run to remove the controls added by "ContextMenusShowName()"
Dim myCB As CommandBar
Dim myCBB As CommandBarButton
Dim myCBC As CommandBarControl
Dim myCBBCaption As String
Dim myCBCs As CommandBarControls
For Each myCB In CommandBars
If myCB.Type = msoBarTypePopup Then
Set myCBCs = myCB.Controls
For Each myCBC In myCBCs
If myCBC.Type = msoControlButton _
And myCBC.ID = 1 And myCBC.Tag = "ContextMenusShowName" Then
Debug.Print myCBC.Caption
myCBC.Delete
End If
Next myCBC
End If
Next myCB
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