Make Directory Button (1 Viewer)

dancaw

New member
Local time
Today, 12:18
Joined
Dec 23, 2020
Messages
2
Hello People,

I was wondering if it's possible add a button to create a folder based on two Table fields, the folder uses a template folder to copy? which has subfolders and pre saved template documents

tbl_Tenders

fields: [Tender_No] & {Project_Title]

Button to clone template folder located Z:\Estimates\EstimateStructure

Create Folder Name [Tender_No] - [Project Title] (located in Z:\Estimates\)

Regards

Dan
 

Dreamweaver

Well-known member
Local time
Today, 12:18
Joined
Nov 28, 2005
Messages
2,466
I use this which has works for me for more years than I really want to admit to ;)
Code:
Dim FS
Dim StrExt As String, Ext As String
Dim StrExtShort As String, BasFolder As String
Dim AZ As Boolean
On Error GoTo HandleErr

    StrExtShort = "\" & StrArt

StrExt = Trim(DLookup("ArtistsFolder", "StblPreferences") & StrExtShort)
'Debug.Print StrExt
Set FS = CreateObject("Scripting.FileSystemObject")
If Not FS.FolderExists(StrExt) Then
        FS.CreateFolder (StrExt)
        FS.CreateFolder (StrExt & "\Recording Covers")
        FS.CreateFolder (StrExt & "\Recording Covers\Singles")
        FS.CreateFolder (StrExt & "\Recording Covers\Albums")
        FS.CreateFolder (StrExt & "\Recording Covers\DVD Video")
Else
       StrExtShort = ""
End If

CreateFolders = StrExtShort
  
Set FS = Nothing

HandleExit:
    Exit Function
  
HandleErr:
    Select Case Err.Number
        Case 76
            MsgBox "Cannot find main folder please check the location of your A-Z folders", vbCritical + vbOKOnly, "Folder create failed"
            Exit Function
        Case 2501 'Cancel = True
            Exit Function
        Case Else
            MsgBox Err.Number & vbCrLf & Err.Description
            Resume HandleExit
        Resume
    End Select
End Function

I have edited this so you will need to update it for your needs
 

dancaw

New member
Local time
Today, 12:18
Joined
Dec 23, 2020
Messages
2
Thank you, i will have a play around
 

Isaac

Lifelong Learner
Local time
Today, 04:18
Joined
Mar 14, 2017
Messages
8,777
Just as info you can also use MkDir
Although like Mick, I actually also prefer the scripting filesystemobject - because inevitably you often end up needing to do more than the first action, in which case, the more robust FSO has it all. : )
 

Users who are viewing this thread

Top Bottom