Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA--Suppress error message,corrupt file or unrecognizable format
I'm using Excel 2003.
I'm looping through files, opening them, and writing info into another Excel spreadsheet. I need to check for corrupt excel files and unrecognizable formats. I'm getting close, but I'm getting the error message "this file is not in a recognizable format" and the user would have to remember to select "cancel" (and not "OK"). I'd like to suppress this error message. My code: In my sub: Global FileIsCorrupt as boolean Global NewFileToCheck as string Global FileName as string Global Path as string (Filename and path are set at this point...) OpenFileAndCheck 'call function If FileIsCorrupt = True then 'if true, file is corrupt or unrecognizable msgbox ("msg to user that it is corrupt and file is being skipped') GoTo FoundCorruptFile ' skips over writing info from file End if ===== Function OpenFileAndCheck() as Boolean On Error GoTo ErrHandler FileIsCorrupt = False 'set to false--it will be reset to true if file is corrupt Set NewFileToCheck = Workbooks.Open(Filename:=Path & FileName) Exit Function ErrHandler: If Err < 0 then FileIsCorrupt = Tre End if End Function ===== Your help would be so appreciated! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
file format or file extension is not valid...error message | Excel Discussion (Misc queries) | |||
How to suppress XML import error message | Excel Programming | |||
Unrecognizable format when opening file | Excel Discussion (Misc queries) | |||
Unrecognizable file format | Excel Discussion (Misc queries) | |||
Suppress error message with saveas | Excel Programming |