I try with the form to enter the directory, the name of the parent folder and then select through the tabs which subfolders will be displayed in the parent folder using a range of checkboxes.

I can enter the drive, the project name and the project number, which first checks if the parent folder exists and if it is not created.
Then I check if the "Use the Internet" checkbox is turned on, and if so, create an array of the names of all the other checkboxes on the "Online" tab. This becomes complicated because I want to skip each of the flag names to check if each of them is active, and if so, I want to capture the “signature” of each flag and use it to create a subfolder in the parent directory (if it does not already exist) )
When I execute my current code, I get "Runtime Error" 424 "Required Object and String
If itm.Value = True Then
highlighted in yellow.
All the code used for the “create folders” part of this user form can be found below:
Private Sub create_folders_button_Click() 'Create a variable for the drive letter Dim driveLetter As String driveLetter = drive_list.Value 'Create a variable for the project name Dim projectName As String projectName = p_name_textbox.Value 'Create a variable for the project number Dim projectNumber As String projectNumber = p_number_textbox.Value 'Create a variable for the constructed BasePath Dim BasePath As String 'Create a new file system object for handling filesystem manipulation Set fs = CreateObject("Scripting.FileSystemObject") 'Populate an array with the online subfolders Dim onlineSubfolders As Variant onlineSubfolders = Array("online_progCosts", "online_exports") 'Compile the basePath BasePath = driveLetter & projectName & " (" & projectNumber & ")" 'Check if the project folder already exists and if so, raise an error and exit If Dir(BasePath, vbDirectory) <> "" Then MsgBox BasePath & " already exists", , "Error" Else 'Create the project folder MkDir BasePath MsgBox "Parent folder creation complete" If online_toggle.Value = True Then Dim online As String online = "Online" MkDir BasePath & "\" & online Dim itm As Variant For Each itm In onlineSubfolders If folder_creator_window.Controls(itm).Value = True Then Dim createFolder As String createFolder = folder_creator_window.Controls(itm).Caption NewFolder = BasePath & "\" & online & "\" & createFolder If fs.folderexists(NewFolder) Then 'do nothing Else MkDir NewFolder End If Else 'do nothing End If Next itm Else MsgBox "The online folder was not created because it was not checked" End If End If End Sub
source share