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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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