PDA

View Full Version : Right Click Context Menu Identification



gmaxey
10-08-2014, 07:13 AM
Does anyone know the name of the right click context menu that appears when you drag and drop text with the right mouse button depressed? The menu displays:

Move here
Copy here
Link here
Create hyperlink here
Cancel

snb
10-09-2014, 05:53 AM
You could check using:


Sub M_snb()
On Error Resume Next

For Each cb In CommandBars
If Replace(cb.Controls(1).Caption, "&", "") = "Move here" Then MsgBox cb.Name
Next
End Sub

gmaxey
10-09-2014, 06:37 AM
snb,

While I see the advantage of your replace method, I had tried identification using code:


Sub ScratchMacro()
Dim oCB As CommandBar
Dim oCtrl As CommandBarControl
Dim i As Long
For Each oCB In CommandBars
If oCB.Controls.Count = 4 Then
Debug.Print oCB.Name
For Each oCtrl In oCB.Controls
Debug.Print oCtrl.Caption
Next oCtrl
End If
For i = 1 To 5
On Error GoTo Err_Control
If oCB.Controls(i).Caption = "&Link here" Then
Debug.Print oCB.Controls(i).Caption
Debug.Print oCB.Name
End If
Next i
NextoCB:
Next
Exit Sub
Err_Control:
Resume NextoCB
End Sub


While the menu is clear a contextual menu, it does not appear to be an accessible member of the commandbars collection.