Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 

Tags
vba, word 2003



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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:43 PM.


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