Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How to handle the message: Run time error '58 "File already exists" when renaming a file to an existing file name ?

I am developing an Access application with Access VBA.

How to handle the message: Run time error '58 "File already exists" when renaming a file to an existing file name. Is there a way to send a MsgBox with this error instead of the Microsoft Visual Basis run time error being generated ?

For ex:

sfile = "\\nydfs1\root\lib\CONTROLLERS\IIG\CASH_CONTROL\ccshared\AbandonedProperty\UDL\Access\UDLLexisNexis\Morgan_Stanley_UDL_LN_prc" & ".xls"

If isFileExist(sfile) Then
    Name sfile As Left(sfile, Len(sfile) - 4) & "_" & Format(Date, "yymmdd") & ".xls"
End If
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial