Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook problem ("no custom dictionary exist") Sanjay Excel Discussion (Misc queries) 1 November 28th 08 06:53 PM
Excel VBA - Copy Folder problem PaulC Excel Programming 5 August 15th 04 12:08 AM
How to: check if folder exist, if not, create escorido[_2_] Excel Programming 2 July 9th 04 01:28 PM
Excel VBA - deleting populated folder problem PaulC Excel Programming 5 April 13th 04 11:45 PM
How to check if a folder/directory exist using VBA wellie Excel Programming 1 March 1st 04 02:24 AM


All times are GMT +1. The time now is 10:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"