Results 1 to 5 of 5
  1. #1
    mmaule is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    38

    Make Path

    Why is this not working?

    Where sPath is C:\Access DB\XML_Output\ATMS-DS\Input\Directives

    Function funMakePath(sPath As String) As Boolean
    '
    ' Tests if path exists
    ' If path does not exist, creates path
    ' Returns True
    '
    Dim intPoint As Integer
    Dim strPathPart As String
    Dim strDir() As String
    intPoint = 0
    funMakePath = False
    '
    ' Initially test if path exists
    '
    If Len(Dir(sPath)) > 0 Then ' If path exists
    funMakePath = True
    Exit Function ' funMakePath
    Else
    GoSub MakeDirectories
    End If ' Len(Dir(sPath))
    Exit Function ' funMakePath
    '
    MakeDirectories:
    strPathPart = ""
    strDir = Split(sPath, "\")
    strPathPart = strDir(0)
    For intPoint = 1 To UBound(strDir) - 1
    strPathPart = strPathPart & "\" & strDir(intPoint)
    If Len(Dir(strPathPart)) = 0 Then


    MkDir strPathPart
    End If
    Next
    funMakePath = True
    Return
    End Function ' funMakePath

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    What are you trying to do?

    With no concept of what you are actually trying to do fixing problems is.... difficult

  3. #3
    mmaule is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    38
    I am trying to test if path exists and if it does not exist, create it.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    Code:
    Dim fs
    Dim directoryarray
    Dim arrayitem
    Dim sPath
    Dim sPathConc
    
    sPath = "c:\Access DB\XML_Output\ATMS-DS\Input\Directives"
    Set fs = CreateObject("Scripting.filesystemobject")
    directoryarray = Split(sPath, "\")
    
    For Each arrayitem In directoryarray
        sPathConc = sPathConc & arrayitem & "\"
        Debug.Print sPathConc
        If fs.folderexists(sPathConc) Then
            'do whatever if the folder already exists
        Else
            fs.createfolder (sPathConc)
        End If
    Next arrayitem
    Set fs = Nothing
    you have to recursively create directories if they do not exist.

  5. #5
    mmaule is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    38
    Modified my code with the information you provided and it works great.

    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 05-27-2014, 05:41 AM
  2. Need help with network path....
    By cplmckenzie in forum Programming
    Replies: 8
    Last Post: 03-27-2013, 08:40 PM
  3. Wrong path
    By djb1011 in forum Queries
    Replies: 1
    Last Post: 02-23-2013, 12:21 AM
  4. Replies: 3
    Last Post: 11-24-2012, 08:56 AM
  5. Change Path of Make Table Query
    By Arnie49 in forum Access
    Replies: 0
    Last Post: 03-14-2010, 05:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums