Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
bad file name
Hello all
The following line returns a run time error 52 (bad file name) occasionally when sName does not exist: If Dir(sName) < "" Then The If block code should be skipped when sName does not exist, not return an error. The error occurs sporadically. Most of the time, the code performs as expected. When the error occurs, it will not repeat in debug mode (it steps through the line just fine). Am I doing something wrong with the Dir statement or is there a more stable way to check for the existence of sName without creating a lot of overhead? TIA Mike |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
bad file name
Dim sStr as String
sStr = "" On error resume next sStr = Dir(sName) On Error goto 0 if sStr < "" then -- Regards, Tom Ogilvy "Mike Archer" wrote in message ... Hello all The following line returns a run time error 52 (bad file name) occasionally when sName does not exist: If Dir(sName) < "" Then The If block code should be skipped when sName does not exist, not return an error. The error occurs sporadically. Most of the time, the code performs as expected. When the error occurs, it will not repeat in debug mode (it steps through the line just fine). Am I doing something wrong with the Dir statement or is there a more stable way to check for the existence of sName without creating a lot of overhead? TIA Mike |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
File:1 and File:2 -- Double Files when Opening One File | Excel Discussion (Misc queries) | |||
I saved file A over file B. Can I get file B back? | Excel Discussion (Misc queries) | |||
opening an excel file opens a duplicate file of the same file | Excel Discussion (Misc queries) | |||
I SAVED A FILE OVER ANOTHER A FILE IN EXCEL. THE OLD FILE WAS AN . | Excel Discussion (Misc queries) | |||
i received a file that reads powerpoint document file file exten. | Excel Discussion (Misc queries) |