![]() |
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 |
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 |
All times are GMT +1. The time now is 11:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com