I'm messing about and have created a macro to run all attached macros.
I started with ISldWorks::RunAttachedMacro method
The macros run as expected but I noticed that multiple copies of the macro were open in the VBA Editor.
I then switched to ISldWorks::RunMacro2 method as I noticed there is the unload after run option but it didn't make any difference.
Seems dodgy to me - or am I missing something?
Run Macro Unload After Run
Re: Run Macro Unload After Run
I get some different results.
persistent launcher:
the macro:
If I run with RunMacro2 it seems to properly unload from the side panel. RunMacro leaves it there as expected. Might have to do with the content of your child macro, maybe an open file reference or something. What happens if you simplify the launched macro?
persistent launcher:
Code: Select all
Public swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
UserForm1.Show
End Sub
'with button to launch
Private Sub CommandButton1_Click()
Dim r As Boolean
Dim err As Long
r = swApp.RunMacro("Y:\Downloads\Macro1.swp", "Macro11", "Main")
'r = swApp.RunMacro2("Y:\Downloads\Macro1.swp", "Macro11", "Main", swRunMacroOption_e.swRunMacroUnloadAfterRun, err)
End Sub
Code: Select all
Sub main()
Debug.Print ("subMacro")
End Sub
Re: Run Macro Unload After Run
Thanks for looking @colt@
I was still in the testing stage so my code was almost identical to yours, except it was a msgbox and a rude word ;p
I was still in the testing stage so my code was almost identical to yours, except it was a msgbox and a rude word ;p