3 Replies Latest reply on Jun 6, 2015 7:14 AM by Ivana Kolin

    VBA modeless form (initialized in macro A) closes when macro A is launched from macro B

    John Alexander

      Sorry about the long title,

       

      I have a VBA macro that utilizes a vbModeless form as the primary interface. I don't believe it can be modal because some of the callback functions require user interaction while the form is visible. It is initialized in a main sub; when the sub ends, the form continues to respond to user input. This is the desired behavior and it works fine when I run directly from Solidworks.

       

      There is an add-in that a predecessor at my company set up which organizes macros into one convenient context-sensitive panel. I configured this add-in to launch my macro; when I run the macro from the add-in the form is displayed and the main subroutine launches normally. However, when the main sub is over, the form disappears. I haven't looked at how the add-in launches these macros but I'm assuming it does some sort of cleanup when the subroutine is finished and this is what is closing (unloading?) the form.

       

      I'm wondering if there is a solution that doesn't require modifying the add-in as I would prefer not to introduce unexpected behavior to a tool with such a broad scope. Can I force the main subroutine to hang until the form is closed? I'm aware of the DoEvents loop but it seems sort of clunky.

       

      Thanks,

       

      John