+ Reply to Thread
Results 1 to 4 of 4

creating a folder with an user input filepath and user input folder name

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    creating a folder with an user input filepath and user input folder name

    Hi all,

    What I was looking for :
    1. Using VBA, a way to create a new folder in a user defined filepath
    2. 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
    Last edited by subbby; 09-04-2012 at 10:04 AM. Reason: solved

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: creating a folder with an user input filepath and user input folder name

    it's not clear for me, you can give a practical example ?
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: creating a folder with an user input filepath and user input folder name

    Hi, subbby,

     MkDir (xDirect & "\filenewname")
    handles everything within the quotation marks as a constant. Please try
     MkDir (xDirect & "\" & filenewname)
    Ciao,
    Holger

  4. #4
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: creating a folder with an user input filepath and user input folder name

    @Holger...

    Thast exactly i was looking for... thanks a ton

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1