Sub ErrorTrap2()
Dim MyFile As String, Message As String
Dim Answer As String
On Error GoTo errTrap
Workbooks.Add
MyFile = "C:\Data.xls"
Kill MyFile
ActiveWorkbook.SaveAs FileName:=MyFile
ActiveWorkbook.Close
Exit Sub
errTrap:
Message = "Error No: = " & Err.Number & vbCr
Message = Message & Err.Description & vbCr & vbCr
Message = Message & "File does not exist"
Answer = MsgBox(Message, vbInformation, "Error")
Resume Next
End Sub
|