Ok, Boyd , but how should look the error handling code from Func1 to stop execution if an error ocured in Proc1(which is a function now, let's say Func2)?
Whith the code below, every time I get an error in Func2 (let's say that one of the .txt files doesn't exist) the application continue to run and import the rest of the files.
Func1()
On Error GoTo ErrHandle
Do While
---some code to select a file from a folder
Call Func2()
Loop
Exit Function
ErrHandle:
MsgBox Err.Description
ExcelWorkbook.Close
Set ExcelWorkbook = Nothing
ExcelApp.Quit
Set ExcelApp = Nothing
Exit Function
End function
Func 2()
---code to import .txt file.
End Function
|