View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mark Mark is offline
external usenet poster
 
Posts: 989
Default kept working, got it working, but...

I kept working, and got it working, but I still suspect it's more complicated
than it needs to be.

Here's what I have:

******************
Sub testdir()

Dim blFolder As Boolean

blFolder = fnCreateFolder("c:\Joe2\Level1\Level2\Level3")


End Sub

Function fnCreateFolder(ByVal stFolder As String) As Boolean

'dimension variables
On Error Resume Next
Dim fs As Object
Dim stFolderTest As String

'assign variables

Set fs = CreateObject("Scripting.FileSystemObject")
stFolderTest = stFolder

'check if dest directory exists



While Not fs.folderexists(stFolder)

fs.createfolder (stFolder)

If fs.folderexists(stFolder) Then


fnCreateFolder = True

Else

While Right(stFolderTest, 1) < "\"

stFolderTest = Left(stFolderTest, Len(stFolderTest) - 1)

Wend

stFolderTest = Left(stFolderTest, Len(stFolderTest) - 1)
fnCreateFolder (stFolderTest)

End If

Wend

End Function