No problems on this side EXCEPT when the said PDF is already open and therefore not overwritten at this time the solidworks and blocked and waits indefinitely for the pdf to be overwritten again I don't know if my problem is very understandable but if anyone has a solution I'm interested :)
Personally, I used a long VBA program to do this... so I'm not going to bring everything back to you;)
But for the part that interested you, my line was slightly different but I wondered if I wanted to write on an already existing file and indicated that it was impossible to write if already opened.
If IsFileOpen(FilePath + FileName + ". DWG") = True Then MsgBox "The "File & FilePath + FileName +". DWG is currently being used by a user and therefore cannot be overwritten." Else longstatus = Part.SaveAs3(FilePath + FileName + ". DWG", 0, 0) End If
to be adapted according to DWG or PDF without forgetting to add a module with the content of Cyril's link.f