Browse Dialog Box

tobyhutton1234

New Member
Joined
Dec 21, 2010
Messages
24
Hi There,

I have a button (browseMain) that brings up a File Browse Dialog box.
When i have selected the file i need the file location into the textbox (browseBox) next to the button.

Any ideas how this is done

Thanks
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Can you post the part of the code that you are using for the file browse dialog box adn the variable you are setting it to?
 
Upvote 0
Here is my code

browseMain is the name of the button where once clicked the browse dialog shows

Code:
Private Sub browseMain_Click()
 
Dim Filter As String, Title As String
Dim FilterIndex As Integer
Dim Filename As Variant
Filter = "View All Files (*.*),*.*," & _
         "Microsoft Excel Spreadsheet (*.xls),*.xls," & _
         "Microsoft WWord Document (*.doc),*.doc,"

FilterIndex = 3
Title = "Select a File to Open"
ChDrive ("I")
ChDir ("I:\Documents")
With Application
    Filename = .GetOpenFilename(Filter, FilterIndex, Title)
    ChDrive (Left(.DefaultFilePath, 1))
    ChDir (.DefaultFilePath)
End With
 
End Sub

The text where the selected file should end up is called 'browseBox'

Thanks
 
Upvote 0
Are you wanting just the file path without the file name in that textbox? I assume it would be something similiar to:

browseBox.text = filename

or if you want just the path:

browseBox.text = left(filename,instrrev(filename,"\"))

Hope that helps.
 
Last edited:
Upvote 0
I modified my last post, see if the last piece works for you, you may have to change .text to .value, its been a while since I have worked with textboxes and I don't have access to Excel at the moment to test it.
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,887
Members
449,057
Latest member
Moo4247

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