Trap the error with On Error GoTo
Sub ErrorTrap()
Dim Answer As Long, MyFile As String
Dim Message As String, currentPath As String
On Error GoTo errTrap
MyFile = "A:\Data.xls"
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=MyFile
Exit Sub
errTrap:
MsgBox "Error No: = " & Err.Number
End Sub
Related examples in the same category