Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

right-click menu in Word

Status
Not open for further replies.

caguila

MIS
Mar 20, 2002
28
GB
Does any one know of a way to hook into (or customize ) the default right-click menu that's displayed when selecting text in Word? eg The menu for Cut, Copy, is there a way to add items to this dropdown menu?
 
Caguila,

Yes, you can customize just about any menu or toolbar. Here is some sample code to customize the popup menu that appears when you right-click in the document area, named "Text".

Code:
Sub CustomPopup()
Dim CBar As CommandBar
Dim CBarCntrl As CommandBarButton

Set CBar = CommandBars("Text")
Set CBarCntrl = CBar.Controls.Add
With CBarCntrl
   .Style = msoButtonCaption
  .Caption = "My Custom Control"
  .OnAction = "MyCustomControl"
End With

End Sub


Sub MyCustomControl()
' Your code here.
  MsgBox "Inside Custom Control Handler", vbInformation + vbOKOnly, "Custom Control"
End Sub


Put this into a Code Module. Run CustomPopup once then right-click inside the doument area to see the effect. Hope this helps.

Regards,
M. Smith
 
rmikesmith,

Thank you very much. That's just what I wanted, didnt know what the command bar would be when you're on the document but this is perfect for what I need.
Christel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top