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
  'ps.ShowDialog
  dn = Left$(ActiveDocument.FullFileName, Len(ActiveDocument.FullFileName) - 4) & ".pdf"
  ActiveDocument.PublishToPdf dn
    dn = Left$(ActiveDocument.FullFileName, Len(ActiveDocument.FullFileName) - 4) & ".pdf"
ExitSub:
Exit Sub
ErrHandler:
 MsgBox "Error occured: " & Err.Description & Err.Number
 Resume ExitSub
End Sub
Parents
  •  1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    Sub PublishToPdf()
    Dim dn As String, ps As PDFVBASettings
      Set ps = ActiveDocument.PDFSettings
      If ActiveDocument.Dirty Then ActiveDocument.Save
      On Error GoTo ErrHandler
      'ps.ShowDialog
      dn = Left$(ActiveDocument.FullFileName, Len(ActiveDocument.FullFileName) - 4) & ".pdf"
      ActiveDocument.PublishToPdf dn
        dn = Left$(ActiveDocument.FullFileName, Len(ActiveDocument.FullFileName) - 4) & ".pdf"
    ExitSub:
    Exit Sub
    ErrHandler:
     MsgBox "Error occured: " & Err.Description & Err.Number
     Resume ExitSub
    End Sub
    
Reply Children
No Data