![]() |
Does folder exist problem
My Code below is attempting to check if a folder exists and if so exit the
sub. Can anyone point me in the right direction mypath = "e:\Temp\" & Actuals If Dir(mypath) < "" Then MkDir mypath Else MsgBox "Folder already Exists" Exit Sub End If For i = lb To ub mypath = "e:\Temp\" & Actuals & Arr1(i) If Dir(mypath) = "" Then MkDir mypath End If Next i |
Does folder exist problem
If Dir(mypath) = "" Then
MkDir mypath Else MsgBox "Folder already Exists" Exit Sub End If -- Regards, Tom Ogilvy "Jeff" wrote in message ... My Code below is attempting to check if a folder exists and if so exit the sub. Can anyone point me in the right direction mypath = "e:\Temp\" & Actuals If Dir(mypath) < "" Then MkDir mypath Else MsgBox "Folder already Exists" Exit Sub End If For i = lb To ub mypath = "e:\Temp\" & Actuals & Arr1(i) If Dir(mypath) = "" Then MkDir mypath End If Next i |
Does folder exist problem
Thx Tom,
I have one more question, how best to trap the error generated when the directory exists and the macro is attempting to overwrite it. How should I capture that error and process it? "Tom Ogilvy" wrote: If Dir(mypath) = "" Then MkDir mypath Else MsgBox "Folder already Exists" Exit Sub End If -- Regards, Tom Ogilvy "Jeff" wrote in message ... My Code below is attempting to check if a folder exists and if so exit the sub. Can anyone point me in the right direction mypath = "e:\Temp\" & Actuals If Dir(mypath) < "" Then MkDir mypath Else MsgBox "Folder already Exists" Exit Sub End If For i = lb To ub mypath = "e:\Temp\" & Actuals & Arr1(i) If Dir(mypath) = "" Then MkDir mypath End If Next i |
Does folder exist problem
On Error Resume Next
mkdir mypath On Error goto 0 -- Regards, Tom Ogilvy "Jeff" wrote in message ... Thx Tom, I have one more question, how best to trap the error generated when the directory exists and the macro is attempting to overwrite it. How should I capture that error and process it? "Tom Ogilvy" wrote: If Dir(mypath) = "" Then MkDir mypath Else MsgBox "Folder already Exists" Exit Sub End If -- Regards, Tom Ogilvy "Jeff" wrote in message ... My Code below is attempting to check if a folder exists and if so exit the sub. Can anyone point me in the right direction mypath = "e:\Temp\" & Actuals If Dir(mypath) < "" Then MkDir mypath Else MsgBox "Folder already Exists" Exit Sub End If For i = lb To ub mypath = "e:\Temp\" & Actuals & Arr1(i) If Dir(mypath) = "" Then MkDir mypath End If Next i |
All times are GMT +1. The time now is 07:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com