check that pdf not exists (dir) and when exists, try to delete it (kill) or check whether file is in use
You have specified the value of third parameter (which is 'Options') as 0 which doesn't exist as per API help. Replace 0 with 1.
boolstatus = swModelDocExt.SaveAs(filename, 0, 1, swExportData, lErrors, lWarnings)
It Sw fails to save PDF document, the return value of 'boolstatus' will be 'False' and you can use this value to show a message to user to notify that PDF document has not been saved. Below are some codes from the macro I use:
'Saves the active drawing as PDF. Warning message if fails to save PDF. bRatval = swModel.Extension.SaveAs(sFilePath, swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent, swExpPDFData, lErrors, lWarnings) If bRatval = False Then swApp.SendMsgToUser2 "Error: Failed to save PDF- " & sFilePath, swMessageBoxIcon_e.swMbStop, swMessageBoxBtn_e.swMbOk Exit Sub End If
Hope this helps.
yes, that worked. not sure where I got the 0, but this macro has been around for a long time.
why setting it to 'Silent' allows it to proceed is strange, but that's just the programmer in me...