I've used the following for to show context menus in any userform textbox in Excel VBA and it has worked very well:
However - when I copied this code and pasted into a Word VBA userform doc I get this:
Macro security settings are set to "enable all macros" in the Trust Settings in Word Options
What is this message telling me, either about the macro not being found or an issue with the security settings ?
Thanks for anyone's help.
cr
Code:
Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then
Set g_txtActiveTextbox = TextBox1
BuildTextboxMenu X, Y
End If
End Sub
Sub BuildTextboxMenu(X As Single, Y As Single)
' Remove any existing reference
On Error Resume Next
CommandBars("MyTextboxMenu").Delete
On Error GoTo 0
With CommandBars.Add(Name:="MyTextboxMenu", Position:=msoBarPopup)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Textbox_Cut"
.Caption = "Cu&t"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Textbox_Copy"
.Caption = "&Copy"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Textbox_Paste"
.Caption = "&Paste"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Textbox_Clear"
.Caption = "Cle&ar"
End With
With .Controls.Add(Type:=msoControlButton)
.OnAction = "Textbox_Select"
.Caption = "Select A&ll"
.BeginGroup = True
End With
.ShowPopup
End With
' remove it
CommandBars("MyTextboxMenu").Delete
End Sub
Macro security settings are set to "enable all macros" in the Trust Settings in Word Options
What is this message telling me, either about the macro not being found or an issue with the security settings ?
Thanks for anyone's help.
cr