Test if main folder and subfolder exist (1 Viewer)

namliam

The Mailman - AWF VIP
Local time
Today, 23:46
Joined
Aug 11, 2003
Messages
11,695
If you only have one variable (in this case path2) you only need one check on path2 that should hold the variable path ...
 

raghuprabhu

Registered User.
Local time
Today, 14:46
Joined
Mar 24, 2008
Messages
154
Hi Megatronixs,

Try this...
 

Attachments

  • TypeReview.zip
    29.8 KB · Views: 81

megatronixs

Registered User.
Local time
Today, 23:46
Joined
Aug 17, 2012
Messages
719
Hi all,

Sorry for the long absence, I just had plenty things to do in the mean time and could not conentrate on the folder creation. But yesterday late I managed to do so.

Please see below code and I hope some one will be able to use it :)

Code:
Private Sub btn_Create_Folder_Click()
    Dim path1 As String
    Dim path2 As String
    Dim myError As String
    Dim TempPath1 As String
    Dim TempPath2 As String
    Dim TempPath3 As String
    Dim TempPath4 As String
    Dim TempPath5 As String
 
    path1 = "C:\Test_Folder\Medium\" & Me.BIN & "_" & RTrim(Me.LE_Name) & "\"
    path2 = "C:\Test_Folder\High\" & Me.BIN & "_" & RTrim(Me.LE_Name) & "\"
 
    If Me.Rating = "Medium" Then
 
    TempPath1 = path1
    TempPath2 = path1 & Me.BIN & "_" & test(Me.Type_Review) & "_" & Format(Me.START_date, "mmmm yyyy") & "\"
    TempPath3 = path1 & Me.BIN & "_" & test(Me.Type_Review) & "_" & Format(Me.START_date, "mmmm yyyy") & "\" & "All Other Documents\"
    TempPath4 = path1 & Me.BIN & "_" & test(Me.Type_Review) & "_" & Format(Me.START_date, "mmmm yyyy") & "\" & "Admin\"
    TempPath5 = path1 & Me.BIN & "_" & test(Me.Type_Review) & "_" & Format(Me.START_date, "mmmm yyyy") & "\" & "Emails\"
 
    If Len(Dir(TempPath1, vbDirectory)) > 0 Then
        If Len(Dir(TempPath2, vbDirectory)) > 0 Then
            MsgBox "Unable to create (all) folders: "
        Else
            MkDir TempPath2
            MkDir TempPath3
            MkDir TempPath4
            MkDir TempPath5
            MsgBox "Folder created successfully!", vbInformation
        End If
    Else
        MkDir TempPath1
        MkDir TempPath2
        MkDir TempPath3
        MkDir TempPath4
        MkDir TempPath5
        MsgBox "Folder created successfully!", vbInformation
    End If
   End If
 
    If Me.Rating = "High" Then
 
    TempPath1 = path2
    TempPath2 = path2 & Me.BIN & "_" & test(Me.Type_Review) & "_" & Format(Me.START_date, "mmmm yyyy") & "\"
    TempPath3 = path2 & Me.BIN & "_" & test(Me.Type_Review) & "_" & Format(Me.START_date, "mmmm yyyy") & "\" & "All Other Documents\"
    TempPath4 = path2 & Me.BIN & "_" & test(Me.Type_Review) & "_" & Format(Me.START_date, "mmmm yyyy") & "\" & "Admin\"
    TempPath5 = path2 & Me.BIN & "_" & test(Me.Type_Review) & "_" & Format(Me.START_date, "mmmm yyyy") & "\" & "Emails\"
 
    If Len(Dir(TempPath1, vbDirectory)) > 0 Then
        If Len(Dir(TempPath2, vbDirectory)) > 0 Then
            MsgBox "Unable to create (all) folders: "
        Else
            MkDir TempPath2
            MkDir TempPath3
            MkDir TempPath4
            MkDir TempPath5
            MsgBox "Folder created successfully!", vbInformation
        End If
    Else
        MkDir TempPath1
        MkDir TempPath2
        MkDir TempPath3
        MkDir TempPath4
        MkDir TempPath5
        MsgBox "Folder created successfully!", vbInformation
    End If
   End If

Greetings.
 

Users who are viewing this thread

Top Bottom