Hello,
Does anyone know why after running one or more macros I go to edit a completely different macro but see the other ones still in the project window? Am I not unloading properly?
The only way i know how to 'clear' them is to go into edit mode and select File / Close and return to Solidworks.
Thanks,
Brad
SolidworksApi macros
Maybe I've misunderstood the whole VBA thing, but it seems to me that once you open or run a macro, it stays cached in memory, even with proper coding. The only way I've found to remove loaded macros is to open the editor, exit the editor and reopen the editor.
Matt Lorono
sw.fcsuper.com
SolidWorks Legion
Follow me on Twitter
Hi,
I stumbled upon a fix for this today. If you use RunMacro2 with the option swRunMacroUnloadAfterRun on itself it will unload itself when you are finished. Hopefully this helps someone:
'Copy paste this function at the end of any macro to force VBA/SWX to let go of it and not hold it in session. This solves the network sharing issue.
'Usage:
Sub Main()
killMacro
End Sub
'The Code:
Sub killMacro()
Dim killApp As SldWorks.SldWorks
Dim killPath As String
Dim killBool As Boolean
Dim killError As Long
Set killApp = Application.SldWorks
killPath = Application.VBE.ActiveVBProject.FileName
killBool = killApp.RunMacro2(killPath, "kill", "me", swRunMacroUnloadAfterRun, killError)
End Sub
Cheers,
Mitch