View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Test for Folder Path. if it doesn't exist, Create it

Hi Barb

You can find code on this page to test
http://www.rondebruin.nl/exist.htm

One way is this

Sub Test_Folder_Exist_FSO_Late_binding()
'No need to set a reference if you use Late binding
Dim FSO As Object
Dim FolderPath As String

Set FSO = CreateObject("scripting.filesystemobject")

FolderPath = "C:\My Folder"
If Right(FolderPath, 1) < "\" Then
FolderPath = FolderPath & "\"
End If

If FSO.FolderExists(FolderPath) = False Then
FSO.CreateFolder (FolderPath)
Else
MsgBox "Folder exist"
End If

End Sub



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Barb Reinhardt" wrote in message
...
I'd like to test for a folder path (Z:\FolderName) and if it doesn't exist,
I'd like to create it. Can someone provide a snippet of code on how to do
this?

Thanks,
Barb Reinhardt