AnsweredAssumed Answered

Macro don't want to open assembly after a while.

Question asked by Mathieu Francois on May 8, 2018
Latest reply on May 8, 2018 by Mathieu Francois

Hi everyone,


I'm having issues with a macro I made.

In our company we have SW PDM (not the professional version). We have 2 big folders in the PDM. One for the parts (but there is some assemblies as well) and one with big assembly (60~120 parts).


I made a macro to capture little JPEGs of the parts/assemblies.

In the macro I run SW in the back, select a folder and go through each file in it. I open the file if it is a .SLDPRT or .SLDASM, do some manipulation about the view (change the background, the display method, select a view (trimetric) and save as a JPEG.


I ran this macro through the folder of parts without any problem (more than 1200 files).

When I ran the macro through the folder of assemblies the macro fails to load assembly past the ~240th file.


You can find the txt version of my macro attached.

I added the


If Part Is Nothing Then

    GoTo nextIteration

End If


after I noticed that the macro failed while it was trying to acces "part" after the load method failed/returned empty.


As the folder is quite big and the operation takes some time I only run the macro when I leave the office (and I checked, nobody cut the link to the PDM or turned off my computer) (to go through the 240 files it took over 50 minutes)


When the macro meet an error it just go to the next iteration and so the next file in the folder. The issue is that past a certain point the load method always returns nothing. As the macro worked fine for the part folder and bug after a number of assembly have been through it I think that I have a memory leak somewhere and that it causes the load option to fail but I can't figure where it is :/


I'm far from an expert in both solidworks and VBA so could you be kind enough to help me debug this ?


Thanks a lot