Run macro from another macro

You need to be logged in to view this content. Please login or become a member.

 Geoff Cameron Womens Jersey

6 Comments

  1. rkeath

    I load both of these Macro’s on to C:\ and it works when I move my Macro’s to the c:\ and edit the macro it will no longer work.

    Dim swApp As SldWorks.SldWorks

    Sub main()
    Set swApp = Application.SldWorks
    swApp.RunMacro2 “C:\Inch.DualDimensionsOn.swp”, “mMain”, “Main”, swRunMacroDefault, Empty
    swApp.RunMacro2 “C:\dxf save.swp”, “mMain”, “Main”, swRunMacroDefault, Empty

    End Sub

    • Hi Russ, you need to change the second and third arguments in the ISldWorks::RunMacro2 method to the names corresponding to:
      1. The module containing the entry sub procedure
      2. The entry sub procedure

      My guess is that at least the module name is wrong.

  2. is8g13

    Hi Keith,

    I have a macro Which calls on another macro. This Calling macro works within the programming environment and opens the called macro (this edits the design table based on a csv file). However it does not actually run this macro. I want to embedded the calling macro such that if I change the csv file, then reopen the part the embedded calling macro will run the design table edit macro.

    any suggestions as to why this procedure is not working?

    • It sounds to me like you aren’t using the right arguments for RunMacro2. You can’t merely specify a path. You also have to specify the correct module name and procedure name. You probably copied my code but then didn’t change out “mMain” (the module name) or “main” (the procedure name) to match your actual module and sub procedure names.

      If you are certain you are using the proper arguments, then you should test your calling macro on a very simple called macro (e.g., one that simply creates a message box). If that works, then you should test your called macro on its own and make sure everything is working properly.

      • is8g13

        Hi Keith,

        I did indeed use your template code and checked the modules and procedure were correct. I know that the design table editing macro works correctly as it has been tested independently. I will check it with a message box and let you know.

        Thanks

        • Thank you for sending me your part. The equation is not being accepted, as indicated by the gray check (which will be green if accepted). Sometimes you need to completely delete out the original equation and design binder macro, then re-add them.

Questions and Comments

You must be logged in to post a comment.