2 Replies Latest reply on Mar 6, 2015 3:04 PM by Solidworks Selim

    Run multiple macros from a single macro

    David Dewey

      Trying to run the following but it is giving me difficulties and saying it cannot open this file. Should I be using some other call to get this to work? I'm simply trying to run two macros sequentially from a single macro.

       

      Dim swApp As Object

      Sub main()

      Set swApp = Application.SldWorks

      Application.SldWorks.RunMacro "<S:\_Templates\Macros\IMI APPROVED UPDATE DAVE - (1.3).swp>", "<APPROVED1>", "<Main>"

      Application.SldWorks.RunMacro "<S:\_Templates\Macros\RELOAD ALL SHEET FORMATS (1.1).swp>", "<TEST_GERMAN1>", "<Main>"

      End Sub

        • Re: Run multiple macros from a single macro
          Keith Rice

          1. You shouldn't have opening or closing brackets in any of those strings.

           

          2. You should not be using "Application.SldWorks" in place of your ISldWorks variable. I would strongly recommend you watch some of the free videos at my web site (for example, "Taking Macros to the People" --- at the bottom of the Videos page) so you avoid these elementary errors.

           

          Your code, assuming that you do have the correct module and sub-procedure names, should look like this:

           

          Dim swApp As SldWorks.SldWorks
          Sub main()
              Set swApp = Application.SldWorks
              swApp.RunMacro "S:\_Templates\Macros\IMI APPROVED UPDATE DAVE - (1.3).swp", "APPROVED1", "Main"
              swApp.RunMacro "S:\_Templates\Macros\RELOAD ALL SHEET FORMATS (1.1).swp", "TEST_GERMAN1", "Main"
          End Sub
          

           

          If you need another example, go to my Macro Library and check out "Run macro from another macro".

           

          Keith

          SolidWorks API Tutorials