Folder Creation Using Command Button

OUFanINkansas

New Member
Joined
Nov 1, 2017
Messages
1
I am attempting to create a folder structure utilizing a dialog box and command button because the folder name will be custom. However, I would like create a folder structure under the unique folder name. I have the following to create the folder required, but am running into trouble recalling the folder name entered in the dialog box to add a folder structure under that folder. Please let me know if further information is required. Thanks!

Private Sub cmdClose_Click()

Unload Me
End Sub

Private Sub cmdOK_Click()

'FILESYSTEMOBJECT/SCRIPTING

Dim FSO As Scripting.FileSystemObject
Set FSO = New Scripting.FileSystemObject


Dim X As String
X = Me.TxtPropNumber.Value
Dim P As String
P = "X:\Proposals\2017"




If FSO.FolderExists(P) Then

FSO.CreateFolder (P & "" & X)





Else
MkDir (P)

End If




'clear the data
TxtPropNumber = ""




End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi, welcome to the board.
Is this what you want
Code:
Private Sub cmdOK_Click()

    Dim P As String
    Dim X As String
    
    X = Me.TxtPropNumber.Value
    P = "X:\Proposals\2017"
    
    If Dir(P, vbDirectory) = "" Then
        MkDir P
    Else
        MkDir (P & "\" & X)
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,060
Messages
6,169,861
Members
452,286
Latest member
noclue2000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top