Not too long ago, I wrote an software to handle files among directories and essential a function to make positive that the directory construction was the same involving the resource and location files. VBA delivers a operate described as MkDir that is made use of to produce a directory,
Microsoft Office 2007 Pro Activation, nevertheless it calls for the parent directory already exists. Here is a function identified as MkTree that can walk a path and develop all of the directories with the tree for any presented file/directory path.
' --------------------------------------------------------------------------
' Function: MkTree
' Goal : Make directories for any provided file name
' Notes : MkTree "c:\a\b\c\file.txt" would formulate directories for c:\a\b\c
' MkTree "c:\a\b\c\" would build c:\a\b\c
' MkTree "c:\a\b\c" would produce c:\a\b
' --------------------------------------------------------------------------
Public Sub MkTree(ByVal strFile As String)
' walk the file and make certain the paths exist
Dim strRoot As String
Dim strPath As String
Dim pos As Integer
' get the root
If (InStr(strFile, ":\") = 2) Then
strRoot = Left(strFile,
Office Pro 2007 Key, InStr(strFile, ":\") + 1)
ElseIf (InStr(strFile, "\\") = 1) Then
strRoot = Left(strFile,
Office 2010 Home And Business Serial cl��, InStr(InStr(strFile, "\\") + 2,
Microsoft Office Professional 2007 Activation, strFile, "\"))
Else
MsgBox "Invalid Root Directory", vbExclamation
Exit Sub
End If
pos = InStr(Len(strRoot) + 1, strFile, "\")
While (pos > 0)
strPath = Left(strFile,
Windows 7 Pro 64bits, pos)
' Set up the directory
On Error Resume Next
MkDir strPath
Debug.Assert Err = 0 Or Err = 75
On Error GoTo 0
pos = InStr(pos + 1, strFile, "\")
Wend
End Sub