Abort function during VBA Macro in SolidWorks

Hello all,

Is there a way to integrate an abort function during a VBA macro when pressing "esc" key ?

I have a macro that saves a drawing to PDF, but sometimes it jams and I cannot stop the macro unless I crash SolidWorks. 

Here is the code:

Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim Filepath As String
Dim FileName As String
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

' Check to see if a drawing is loaded.

If (swModel Is Nothing) Or (swModel.GetType <> swDocDRAWING) Then

swApp.SendMsgToUser ("CODE 18! Open a drawing first and then try again.")

' If no model currently loaded, then exit
Exit Sub

End If
 
Set swDraw = swModel

Filepath = Left(swDraw.GetPathName, InStrRev(swDraw.GetPathName, "\"))

FileName = Left(swDraw.GetTitle, Len(swDraw.GetTitle) - 9)

swDraw.SaveAs (Filepath + FileName + ".PDF")
'swDraw.SaveAs (Filepath + FileName + ".DWG")

End Sub