MACRO LIBRARY

Run macro from another macro

Free public access. No account or subscription required.

Files

CallingMacro.swp CalledMacro.swp

CallingMacro.swp Code

Module: mMain

'Demonstrates how to call one macro from another using ISldWorks::RunMacro2
    
'Preconditions: CalledMacro.swp is currently in C:\
'Results: a message box should be displayed indicating that ISldWorks::RunMacro2 succeeded
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
    
Sub main()
    Set swApp = Application.SldWorks
    swApp.RunMacro2 "C:\CalledMacro.swp", "mMain", "Main", swRunMacroDefault, Empty
End Sub

CalledMacro.swp Code

Module: mMain

'This macro is used in conjunction with CallingMacro. Please see comments in that macro.
    
Dim swApp As SldWorks.SldWorks
    
Sub main()
    Set swApp = Application.SldWorks
    swApp.SendMsgToUser "ISldworks::RunMacro2 succeeded!" & vbCrLf & _
        "This macro was called from another macro."
End Sub