And it is not a solution to write code to shut down wp first, as users may
have multiple documents in wp open.
In some cases, if all your do is run a bunch of macros that does some
processing, loads some labels, prints them etc, then actually the fact of
2nd copies of wp being opened by the macro is a good thing. The user might
be running wp with 3, or a dozen documents open. When we launch a 2nd copy
of wp..we run our processing/macros etc..and then at the very end close down
this 2nd copy of wp. What this means that is in fact we do not disturb, or
bother the existing running copy of wp (and the potentially open ed
documents etc.). And, read carefully:
NO, I am not suggesting to shut down wp first, but I am most certainly
suggesting that at the END OF your macro you shut down wp. That way, if you
runApp the macro 10 times..you don't get 10 copies of wp running (since the
macro when done can shut down wp). As mentioned, if you always launch a 2nd
(or "new") copy of wp to run this macro, and then close down this 2nd (or
"new") copy, then you never disturb the users currently opened documents.
Hence, over the years..this is a possible solution, and a concept you seem
to have missed.
However, I did also go on to mention that :
In other words, after you macro runs..you put the computer back into the
same state it was before. If none copies of wp were running at the start of
this process, then at the end of the process...none will be running. And, of
course if the user have wp open..then that users copy will remain
opened..and we don't disturb it. So, we launch our own copy...do our
work..and close it.
However, if the macro requites user intervention, or the results in a
working document for the user AFTER the macro runs and that the user needs
to work on this document, then my suggestion is of no, or little use.
Obviously, if the user now starts working with the 2nd copy and some
document that we created, then we can't close this additional copy of
wp..can we?
So, in summary, if that macro does not need or result in needed wp to be
open...then simply close it when done, and you completely solve the problem
of a additional copies of wp being left running. And, if the macro after
being run needs wp to remain open, then my suggestion is of no use...
I understand that the above may not help you..but you seemed to missed my
point. And, in fact as a general rule and approach to computing problems,
placing the computer back in the same state as to when you code starts is a
traditional solution to many computer problems.
So, yes, you could engage some fancy programming to check if a existing copy
of wp is running, but simply closing down what you opened after you are done
eliminates this need altogether.