Hi all,
What I was looking for :- Using VBA, a way to create a new folder in a user defined filepath
- and whose name is a USER INPUT (using INPUT BOX)
What I tried :
two things
MkDir "C:\Calculations\Rotary Breakers\Rotary Breaker\CG BEARING LOAD$"
this made a file of my choice. However, the filepath changes everytime someone new works on this project and so does its folder name. therefore I tried
Sub tester()
Dim xRow As Long
Dim xDirect$, xFname$, InitialFoldr$
InitialFoldr$ = "G:\"
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a folder to list Files from"
.InitialFileName = InitialFoldr$
.Show
If .SelectedItems.Count <> 0 Then
xDirect$ = .SelectedItems(1) & "\"
End If
End With
MkDir "xDirect$"
End Sub
also tried :
Dim filenewname As String
filenewname = Application.InputBox _
(Prompt:="Enter the name.", _
Title:="name name", Type:=2)
MkDir (xDirect & "\filenewname")
Result : always created a folder by the name "filenewname"
Now this just takes me to the path. It neither asks for a folder name nor creates a new folder.
My doubts:- where to write the code for the input box in the above code? is it after "END WITH" line ?
- How to modify MkDir command so as to create a new folder based on the new user input (the folder name)
-subbby
Bookmarks