How to skip "unrecognizable" msg when opening Workbook
I use the following code to try and open a downloaded csv file:
========================
Function OpenCSVFile(csvFileName) As Boolean
On Error GoTo FailedOpen
Application.Workbooks.Open csvFileName
OpenCSVFile = True
Exit Function
FailedOpen:
OpenCSVFile = False
End Function
==================
Sometimes the CSV is not guaranteed to be readable, and when it can't open,
a dialogue comes up saying "This file is not in a recognizable format." I
would hope this would be caught by "On Error", but it doesn't catch it. It's
a large batch process and I don't want it to be halted by a bad CSV file, i
want the error to be logged and continue.
Any idea on how I can prevent this? A way to supress the dialogue, or to
check a file for validity before even trying to open it?
Thanks,
Mayhew
|