Annoying Dialog Box Behavior, Populating with Previously Used Values

Jun 21, 2007 0 Replies

Have you ever noticed that annoying Dialog Box behavior where it (sometimes) populates with previously used values (usually when you don't want it to), rather than the initial values you specified...I finally figured a way around it.



Since SolidWorks actually keeps macros open in the background after you run them as discussed in:

formatting link
Even tho I Unload the Form at the end of each macro, I think somehow it is not getting completely unloaded. I noticed that values set in any Procedures not under a dialog box, seemed to always work. But values specified in the UserForm_Initialize event or even just the default values of the dialog box...where not being correctly initialized during subsequent runs of a macro during a SolidWorks secession. After some experimenting, and finally getting it to repeat I found that the UserForm_Initialize event procedure was not being called during the runs that were populating with the previously used values.



The solution that seems to be working so far is to add a "Unload Userform1" line right before the "Load Userform1" call. If you have multiple "Load Userform1" line calls (if for whatever reason you are opening and closing a Userform multiple times during a single processing of the macro), then you only need to add the "Unload Userform1" line before the *first* "Load Userform1" call.



Later, Ken



Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required