Results 1 to 2 of 2

Thread: Sub directories

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    Question

    Hello busy beez

    Can anyone rectify this problem... how to create a folder within a folder at the same instruction.. ie:

    c:\folder1\folder2

    my code so far

    Private Sub CreateFolders_Click()
    If Dir(Products.text, vbDirectory) = Products.text Then
    MsgBox "Already exists"
    Else
    MkDir "c:\" + Products.text + ??????????
    End If
    End Sub

    Regards

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    Omaha, Ne
    Posts
    65

    Cool Sub Directory

    I don't think you can create sub directories under non-existent directories. You have to build the path one directory at a time and work your way down. Maybe something like this would work for you:

    If Len(Dir$(products.text, vbDirectory)) <= 0 Then
    Dim Fpath As String
    Dim Branches() As String
    Dim b As Integer
    Branches = Split(products.text, "\")

    For b = LBound(Branches) To UBound(Branches)
    Fpath = Fpath & Branches(b) & "\"
    If Len(Dir$(Fpath, vbDirectory)) <= 0 Then
    MkDir Fpath
    End If
    Next b

    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width