Microsoft Office Forums vba Word: How to add selected text into right click menu, or add right clicked word in menu

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-10-2018, 12:14 AM
digitalsindh@gmail.com digitalsindh@gmail.com is offline vba Word: How to add selected text into right click menu, or add right clicked word in menu Windows 10 vba Word: How to add selected text into right click menu, or add right clicked word in menu Office 2013
Novice
vba Word: How to add selected text into right click menu, or add right clicked word in menu
 
Join Date: Oct 2018
Posts: 1
digitalsindh@gmail.com is on a distinguished road
Wink vba Word: How to add selected text into right click menu, or add right clicked word in menu

I want to add Selected text into right click menu as a .caption
here is my code


Code:
PublicSub CreateMacro()
Application.CommandBars("Text").Reset

    Dim MenuButton As CommandBarButton
    With CommandBars("Text")
        Set MenuButton =.Controls.Add(msoControlButton)
        
        
        With MenuButton
            .Caption = Selection.Text
            
            
            
            
            .Style = msoButtonCaption
            .OnAction ="Test_Macro"
        EndWith
    EndWith

    
EndSub

PublicSub Test_Macro()
    MsgBox "I work"
    ResetRightClick
    CreateMacro
EndSub

Sub ResetRightClick()
    
    Application.CommandBars("Text").Reset
         
EndSub

on first attempt right click menu is displayed but empty caption, and on next times it show older caption (not current selection) until the menu item is clicked
or how to add Right clicked word into right clicked menu
Reply With Quote
  #2  
Old 10-10-2018, 01:23 AM
macropod's Avatar
macropod macropod is offline vba Word: How to add selected text into right click menu, or add right clicked word in menu Windows 7 64bit vba Word: How to add selected text into right click menu, or add right clicked word in menu Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,486
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Cross-posted at: http://www.vbaexpress.com/forum/show...clicked-word-i
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 10-10-2018, 02:02 AM
gmayor's Avatar
gmayor gmayor is offline vba Word: How to add selected text into right click menu, or add right clicked word in menu Windows 10 vba Word: How to add selected text into right click menu, or add right clicked word in menu Office 2016
Expert
 
Join Date: Aug 2014
Posts: 2,764
gmayor is just really nicegmayor is just really nicegmayor is just really nicegmayor is just really nice
Default

Also at https://social.msdn.microsoft.com/Fo...a-f4e64733076f
__________________
Graham Mayor - MS MVP (Word)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 10-10-2018, 04:35 AM
slaycock slaycock is offline vba Word: How to add selected text into right click menu, or add right clicked word in menu Windows 7 64bit vba Word: How to add selected text into right click menu, or add right clicked word in menu Office 2016
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

And at

https://stackoverflow.com/questions/...ht-clicked-tex
Reply With Quote
Reply

Tags
vba, word 2003

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba Word: How to add selected text into right click menu, or add right clicked word in menu Microsoft Word: How to Add Thesaurus Option in right click menu mithun Word 2 12-14-2016 10:38 AM
Modify right-click context menu to only allow pasting text derajlance Word VBA 0 05-24-2016 02:25 PM
vba Word: How to add selected text into right click menu, or add right clicked word in menu Microsoft Word, right click in document-how make text larger in menu pcumming Word 1 02-07-2015 07:47 PM
Adding Macro menu to the right click menu (Word 2007) masam123 Word 0 10-14-2011 04:05 AM
How to get the Name of the selected menu anil3b2 Word 0 07-26-2010 02:44 AM


All times are GMT -7. The time now is 02:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft