Rich Dobleman

saveas pdf vba api crashes

Discussion created by Rich Dobleman on Dec 29, 2016
Latest reply on Jan 6, 2017 by bill bothe

Wanted to share my experience with this vba macro because I could find nothing about it.  Briefly, the macro loops through many parts one at a time:  it opens, modifies a model and drawing and outputs several formats, including pdf, then closes them and loops to the next part.

 

The problem:  solidworks was sometimes crashing at the "modeldocextension.saveas" (to pdf) api call.  It turns out the problem was eliminated when I changed the layer set to "will not print" to "will print" in the drawing (did this manually by clicking on the layer properties button, not programmatically).  This behavior is confirmed in another macro which works totally differently.  Note other conditions: only an annotation was on the layer, not attached to anything (or it is attached to the sheet view), and it is hidden, on a standard drawing fully rebuilt, model loaded and rebuilt, running 2016 service pack 5 on windows 7 pc.  Hope this helps the next person.

Outcomes