if swapp is nothing.....

Programming and macros
User avatar
Hansjoerg
Posts: 113
Joined: Thu Apr 01, 2021 4:17 pm
Answers: 3
x 71
x 60

if swapp is nothing.....

Unread post by Hansjoerg »

hello all,

for a new macro project I searched the net for some code snippets.

In one of the references I have found a query whose sense I do not understand.

'check if application is open
if swapp is nothing then
msgbox "to execute the macro, swx must be open"
.....

what the query checked i still understand, but does that make sense with a swp macro at all? can the case occur at all?

A macro in swp format can only be executed via the corresponding function in swx, as far as I know you can't even run the macro editor without swx active, so starting the macro via the editor without swx active is also out of the question.
Why do i need this query then?
All the "good" news about SWX makes me feel like I'm driving a truck with two trailers straight into a dead end.
User avatar
Tom G
Posts: 355
Joined: Tue Mar 09, 2021 9:26 am
Answers: 0
Location: Philadelphia, PA area
x 989
x 466

Re: if swapp is nothing.....

Unread post by Tom G »

Maybe it crashed before completing? Otherwise, I have no idea there.
User avatar
SPerman
Posts: 2044
Joined: Wed Mar 17, 2021 4:24 pm
Answers: 14
x 2222
x 1869
Contact:

Re: if swapp is nothing.....

Unread post by SPerman »

Since those files are VB6/VBA code, I assume it could be launched from other applications. I think you would have to put effort into making such a thing happen, but in theory it could be done.
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
User avatar
AlexLachance
Posts: 2179
Joined: Thu Mar 11, 2021 8:14 am
Answers: 17
Location: Quebec
x 2356
x 2011

Re: if swapp is nothing.....

Unread post by AlexLachance »

swp is not strictly prohibited to SolidWorks, but I'm not sure why one would try to run the macro anywhere else then SW
User avatar
HerrTick
Posts: 207
Joined: Fri Mar 19, 2021 10:41 am
Answers: 1
x 32
x 307

Re: if swapp is nothing.....

Unread post by HerrTick »

Perfectly valid safety check. Not only does SW need to be running, but the code needs a valid SW application object. If that object ("swApp") gets disconnected somehow, then all of the code will not run.
Post Reply