Hi caguila
I got this piece of code from the Web ( can't remember where ). It display a form in Word and when the mouse is right-clicked (within the form) a popup menu appears. Here is the code.
The form consists of a Label and a Close button.
Private Sub btnClose_Click()
Me.Hide
End Sub
' each object in the UserForm can have it's own popup menu assigned to it.
Private Sub Label1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then ' the right mouse-button was clicked
DisplayCustomPopUp
End If
End Sub
' the UserForm can have it's own popup menu assigned to it.
Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then ' the right mouse-button was clicked
DisplayCustomPopUp
End If
End Sub
The code in Module1
Option Explicit
Const PopUpCommandBarName As String = "TemporaryPopupMenu"
Sub DeletePopUp() ' deletes the custom popup menu
On Error Resume Next
CommandBars(PopUpCommandBarName).Delete
On Error GoTo 0
End Sub
Sub CreatePopUp() ' creates the custom popup menu
Dim cb As CommandBar
DeletePopUp
Set cb = CommandBars.Add(PopUpCommandBarName, msoBarPopup, False, True)
With cb
With .Controls.Add(Type:=msoControlButton)
.OnAction = "MyMacroName"
.FaceId = 71
.Caption = "Custom Menu 1"
.TooltipText = "Custom Tooltip Text 1"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "MyMacroName"
.FaceId = 72
.Caption = "Custom Menu 2"
.TooltipText = "Custom Tooltip Text 2"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "MyMacroName"
.FaceId = 73
.Caption = "Custom Menu 3"
.TooltipText = "Custom Tooltip Text 3"
End With
End With
Set cb = Nothing
End Sub
Sub DisplayCustomPopUp() ' displays the custom popup menu
Application.CommandBars(PopUpCommandBarName).ShowPopup
End Sub
Sub DisplayExampleUserForm() ' displays the form
Load UserForm1
UserForm1.Show
Unload UserForm1
End Sub
Sub MyMacroName() ' dummy macro attached to the popup menu items
MsgBox "This could be your macro running!", vbInformation, ThisDocument.Name
End Sub
Hope this is what you're refering.
rgrds
LSTAN