In my VBA macros with non-modal userforms, it is often the case that I want to "hand control back to CorelDRAW" after the macro has done something. For example, if the macro has been used to create a selection, I want focus to go back to CorelDRAW so that the user can directly delete or otherwise work with that selection.
I have been doing this using AppActivate "CorelDRAW".
Most of the time, this works fine, but on occasion, this will generate a runtime error 5 - Invalid procedure call or argument.
Once this starts happening, it keeps happening - with any macro in which I do that, and with some macros written by others. I can't see their code, but I'm assuming that they are doing something similar to what I am.
Shutting down and restarting CorelDRAW does not fix this. If I log off of Windows, then log in again, everything is fine.
Any suggestions for how to avoid this problem with my VBA macros?
If I use Application.ActiveWindow.Activate, then I seem to get the desired result.
Good idea? Bad idea?
in X6 only AppActivate "CorelDRAW". works. Without any error. But since you said it may happen I put the code between On error resume Next and On error Go to 0...
Application.ActiveWindow.Activate does not work... At least in my Corel installation
.