I'm in the process of trying to set a macro up to hotkey saving PDF and DXF files out for production drawings. At the moment it's pretty much the same as the Solidworks API example found here: 2017 SOLIDWORKS API Help - Save File as PDF Example (VBA)
I know the code works as I've been able to save out both file types from Solidworks into the relevant folders within the PDM and locally with little to no issue. The problem comes when trying to save a PDF which is write locked in the PDM (either not checked out or released etc) as Solidworks locks up causing the need to restart it entirely. If the file is new or checked out there's no issue and the file saves fine.
The line which is failing is the following:
boolstatus = swModelDocExt.SaveAs(pdflocation, 0, 0, swExportPDFData, lErrors, lWarnings)
At a guess I'd say it's trying to write to the file, failing then getting stuck in a loop, however I don't face the same issue when saving out DXF files which are also checked out. These appear to fail gracefully by flagging boolstatus false which then pops up a warning message box.
Is there any kind of check I can add to scan the PDM location status to prevent the file from writing something which is always going to fail? Alternatively is there any other save function I'm unaware of which would avoid this issue entirely?
Apologies if this is a re-post, I've been searching for the last few hours bouncing between Solidworks and VBA help pages, but it seems that it's the PDM causing the problem rather than the process I'm taking.