Error Handling - Import CSV file

30percent

Board Regular
Joined
May 5, 2011
Messages
123
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have an excel where each time after the user bring it up, he or she would click in a button that call the procedure refresh().

Code:
Sub refresh()    
ThisWorkbook.RefreshAll
    Call timer
End Sub


Sub timer()
    Application.OnTime Now + TimeValue("00:10:00"), "refresh"
End Sub

On the excel, I have a workbook connection that import "test.csv" into a worksheet. While "test.csv" is being downloaded from the server on every 10 minute interval - there are occasion the refresh() procedure is being run at the same time the "test.csv" is still being downloaded causing the excel to throw error message "Someone else is working in "test.csv" right now. Please try again later".

How can I handle the error so that:
1) it would not throw the error message
2) try to import again in say 5 mins later
3) if 15 mins later or 3 tries later, excel still unable to import the file, then throw and error message "We tried to import test.csv for the 15 mins but are still unable to import the file."

Thank you!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top