Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't know much, but you might want to try
application.displayalerts=false/true 'false at the beginning, true at the end at the beginning/end of the sub? I don't know much about formulas, so I don't know if this would work with it. "Mayhew" wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the suggestion. I neglected to mention that if you click past the
dialog , the corrupt file opens anyway, and I don't want my script running on the garbage file. So I need some way of knowing in my code that the error has occurred, and skipping over that file. "comparini3000" wrote: I don't know much, but you might want to try application.displayalerts=false/true 'false at the beginning, true at the end at the beginning/end of the sub? I don't know much about formulas, so I don't know if this would work with it. "Mayhew" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Slow opening of "in use" workbook | Excel Discussion (Misc queries) | |||
"Running Virus Scan" ....On Opening Excel Workbook | Excel Discussion (Misc queries) | |||
How do I automatically "enable Macros" when opening a workbook | Excel Programming | |||
Emptying cache or "history" before opening workbook | Excel Programming | |||
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc | Excel Programming |