saurabh_546
New Member
- Joined
- Sep 7, 2009
- Messages
- 19
Dear all
I am importing a text file into the excel
I am working on errorhandler now
there are only three possible runtime errors i can get
1st is user cancels the procedure
2nd is the destination sheet alerady exists
3rd is if text file is not found
I am able to workout first 2 , i need help on 3rd
here is my code
I am importing a text file into the excel
I am working on errorhandler now
there are only three possible runtime errors i can get
1st is user cancels the procedure
2nd is the destination sheet alerady exists
3rd is if text file is not found
I am able to workout first 2 , i need help on 3rd
here is my code
Code:
ErrorHandler:
If folderName = "" Then
Application.DisplayAlerts = False
ShNew.Delete
Application.DisplayAlerts = True
Exit Sub
Else
If Err.Description = "Cannot rename a sheet to the same name as another sheet, a referenced object library or a workbook referenced by Visual Basic." Then
MsgBox "An error was encountered while attempting to import the data." & vbCrLf & Err.Description _
& vbCrLf & "Please rename or delete the sheet before importing the data." & vbCrLf, vbCritical, "Error " & Err.Number
Application.DisplayAlerts = False
ShNew.Delete
Application.DisplayAlerts = True
Else
If Err.Description = "Cannot rename a sheet to the same name as another sheet, a referenced object library or a workbook referenced by Visual Basic." Then
MsgBox "The Folder does not exists" & vbCrLf & "Please select the valid folder." & vbCrLf, vbCritical, "Error " & Err.Number
End If
End If
End If