Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Handling Errors with Workbooks.OpenText
I've got this line of code:
Workbooks.OpenText FileName:=sFilePath & ".xls", _ DataType:=xlDelimited, Tab:=True The file is opened using the path and filename entered by the user into a form. How can I handle errors so that if the file/path is invalid or the file doesn't exist, it gives an error message rather than falling over? Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Handling Errors with Workbooks.OpenText
Hello David
Use an Error Handler eg: Sub tester() On Error GoTo tester_Error Workbooks.OpenText Filename:=SFilepath & ".xls", _ DataType:=xlDelimited, Tab:=True On Error GoTo 0 Exit Sub tester_Error: MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure tester of Module Module1" End Sub HTH Cordially Pascal "David" a écrit dans le message de news: ... I've got this line of code: Workbooks.OpenText FileName:=sFilePath & ".xls", _ DataType:=xlDelimited, Tab:=True The file is opened using the path and filename entered by the user into a form. How can I handle errors so that if the file/path is invalid or the file doesn't exist, it gives an error message rather than falling over? Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Handling Errors with Workbooks.OpenText
On Oct 16, 9:10 am, "papou"
wrote: Hello David Use an Error Handler eg: Sub tester() On Error GoTo tester_Error Workbooks.OpenText Filename:=SFilepath & ".xls", _ DataType:=xlDelimited, Tab:=True On Error GoTo 0 Exit Sub tester_Error: MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure tester of Module Module1" End Sub HTH Cordially Pascal "David" a écrit dans le message de news: . com... I've got this line of code: Workbooks.OpenText FileName:=sFilePath & ".xls", _ DataType:=xlDelimited, Tab:=True The file is opened using the path and filename entered by the user into a form. How can I handle errors so that if the file/path is invalid or the file doesn't exist, it gives an error message rather than falling over? Thanks.- Hide quoted text - - Show quoted text - Thanks Pascal, that was exactly what I wanted. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Workbooks.Opentext - oldskool '97 | Excel Programming | |||
Handling Errors and MessageBox | Excel Programming | |||
Handling errors in formulas (how annoying are they!) | Excel Discussion (Misc queries) | |||
Workbooks.OpenText | Excel Programming | |||
Handling Errors from Worksheet Functions | Excel Programming |