Publish to PDF using macro crashes corelDraw 2019

Hi.  On occasion, I get a program crash when I run this macro to pub a cdr to pdf.  I don't what causes it and I lose work sometimes.  If anyone can check this code I'd be so grateful.

Sub PublishToPdf()
Dim dn As String, ps As PDFVBASettings
  Set ps = ActiveDocument.PDFSettings
  If ActiveDocument.Dirty Then ActiveDocument.Save
  On Error GoTo ErrHandler
  dn = Left$(ActiveDocument.FullFileName, Len(ActiveDocument.FullFileName) - 4) & ".pdf"
  ActiveDocument.PublishToPdf dn
    dn = Left$(ActiveDocument.FullFileName, Len(ActiveDocument.FullFileName) - 4) & ".pdf"
Exit Sub
 MsgBox "Error occured: " & Err.Description & Err.Number
 Resume ExitSub
End Sub
  • I went through your code, you have a line after "ActiveDocument.PublishToPdf dn" that serves no purpose that I can tell. It shouldn't be an issue but it seems to be completely unnecessary. If you change the active document in mid-performance it might cause the program to crash as stated by NudeFan. If you could provide more information it would definitely help!

Reply Children