This is a good one!
I have a form that contains 336 text 'caption' boxes. It is for scheduling jobs. Each box does (or can) hold a job name. The job names are entered on this form from another form.
I have built a right click menu to perform different tasks. When I right click on one of these objects, and then select a item from the list, I get the mouse position of the item on the menu. I need the mouse position of the box that I right clicked.
I included my code although you should not need it. Help please.
Sub CreateNewShortcutMenu()
Dim newButton As CommandBarControl
Dim cmbRightClick As Office.CommandBar
Set cmbRightClick = CommandBars.Add("newRightClick", msoBarPopup, False, False)
Set newButton = cmbRightClick.Controls.Add(msoControlButton, 1, , , False)
With newButton
.Style = msoButtonIconAndCaption
.Caption = "&Invoice" ' Menu caption which shows when right clicked
' .Picture = CurrentProject.path & "\Images\Invoice.png" ' Path to the picture
.OnAction = "=Invoice()" ' name of fuction to call
End With
Set newButton = cmbRightClick.Controls.Add(msoControlButton, 1, , , False)
With newButton
.Style = msoButtonIconAndCaption
.Caption = "&Proposal" ' Menu caption which shows when right clicked
' .Picture = CurrentProject.path & "\Images\Invoice.png" ' Path to the picture
.OnAction = "=Proposal()" ' name of fuction to call
End With
End Sub
Public Function Invoice()
' MsgBox "You clicked on Invoice"
Get_Cursor_Pos
End Function
Public Function Proposal()
' MsgBox "You clicked on Invoice"
Get_Cursor_Pos
End Function
Sub Get_Cursor_Pos()
' Main routine to dimension variables, retrieve cursor position,
' and display coordinates
' Dimension the variable that will hold the x and y cursor positions
Dim Hold As POINTAPI
' Place the cursor positions in variable Hold
GetCursorPos Hold
' Display the cursor position coordinates
MsgBox "X Position is : " & Hold.X_Pos & Chr(10) & _
"Y Position is : " & Hold.Y_Pos
End Sub