Hello
I would have liked to know in VBA how I could exit the macro (Simulate a click on the cross).
Initially I had thought of a "UserForm.Hide" but the macro doesn't close completely.
I also tried "swApp.Exit" or something like that but it closes solidWorks.
Thank you
Do you want to know how the macro should stop? Or how do I exit the macro creation page?
I want to stop the macro, as I said exactly as if I was exiting the userform by means of the cross.
I found on the internet the command "Unload Me", but here is what VBA returns to me:
Compile error: Invalid user of Me keyword
remrem
August 28, 2015, 11:52am
4
Tell us more about your code because "Unload me" only closes the form...
Hello
You should use:
'We unload the memory of the form
Unload Me
'Exit the macro
End
A+
Philippe
Wholesale:
When I launch the macro I launch "Sub main", then main opens a form. When I click on print I call "Sub StartPrint", and I would like that once StartPrint has executed its code it closes my window and unloads the macro from memory (To avoid keeping the options made in the userform in memory).
I don't know if it's clear enough?
pl
August 28, 2015, 2:18pm
8
So to be clearer:
If the goal is to stop "Sub StartPrint", you have to write:
Unload Me
Exit sub' ends the current sub
If the goal is to stop "Sub main" (general macro), you should write:
Unload Me
End 'ends all current subs
1 Like
Very well thank you, well the Unload Me returns this error to me:
Compile error: Invalid user of Me keyword
But on the other hand, by adding "End" at the end, it closes me well and it doesn't keep me in memory as I wish. So for me it's good!
Thank you