I have a simple macro that notifies whenever left mouse button is pressed. and shows the coordinates of the mouse pointer. There is a form with a button on it. When you press the button it starts the mouse event. I want to know how do i bring the command back to code (main) after the event it fired. If you look below i want "Hey" to be displayed after the i press the left mouse button and coordinates at the mouse tip are shown.
I have attached the code as well
I am new to mouse events and did not find anything that could solve this problem. Any help will be appreciated.
Sub main()
UserForm1.Show vbModeless
MsgBox ("Hey")
End Sub
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swView As SldWorks.ModelView
Dim WithEvents swMouse As SldWorks.Mouse
Dim X_, Y_ As Double
Dim listenForClick As Boolean
Private Sub CommandButton1_Click()
Set swModel = swApp.ActiveDoc
Set swView = swModel.ActiveView
Set swMouse = swView.GetMouse
listenForClick = True
End Sub
Private Function swMouse_MouseLBtnDownNotify(ByVal X As Long, ByVal Y As Long, ByVal WParam As Long) As Long
If listenForClick Then
X_ = X
Y_ = Y
MsgBox (X & "; " & Y)
listenForClick = False
Unload UserForm1
End If
End Function
Private Sub UserForm_Initialize()
Set swApp = Application.SldWorks
End Sub
SolidworksApi macros