Browse for folder

rpaulson

Well-known Member
Joined
Oct 4, 2007
Messages
1,428
my current code uses this.
Code:
 fpath = ThisWorkbook.Path

Later in my code I use this path to import some txt files.
This works fine as long as the text files are in the same folder as my excel file.

I would like to have some sort of browse where the user can select the path.

ie. fpath = input (Browse for the location on the files")

Anyone have any ideas?


Ross
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Code:
strPath = InputBox("type in path")

or
Code:
    ' Requires reference to Microsoft Office 11.0 Object Library.
    Dim fDialog As Office.FileDialog
    Dim varFile As Variant
    Dim strFolderPath As String
    
    ' Set up the File Dialog
    Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
    
    With fDialog
        '.InitialFileName = ThisWorkbook.Path
        ' Allow user to make multiple selections in dialog box
        .AllowMultiSelect = False
        
        ' Set the title of the dialog box.
        .Title = "Please select one folder to save data file in"
    
        ' Clear out the current filters, and add our own.
        .Filters.Clear
    
        ' Show the dialog box. If the .Show method returns True, the
        ' user picked at least one file. If the .Show method returns
        ' False, the user clicked Cancel.
        If .Show = True Then
            strPath = .SelectedItems(1)
        End If
    End With
    
    ' Freeing Object Variables
    Set fDialog = Nothing
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

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