sindhu2352
10-10-2018, 12:04 AM
I want to add Selected text into right click menu as a .caption
here is my code
Public Sub 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"
End With
End With
End Sub
Public Sub Test_Macro()
MsgBox "I work"
ResetRightClick
CreateMacro
End Sub
Sub ResetRightClick()
Application.CommandBars("Text").Reset
End Sub
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
here is my code
Public Sub 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"
End With
End With
End Sub
Public Sub Test_Macro()
MsgBox "I work"
ResetRightClick
CreateMacro
End Sub
Sub ResetRightClick()
Application.CommandBars("Text").Reset
End Sub
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