ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding browse button to userform (https://www.excelbanter.com/excel-programming/284027-adding-browse-button-userform.html)

Brad[_11_]

Adding browse button to userform
 
Hi all,

I'm trying to add a browse button to a custom userform.
The goal is to capture the path and filename the user
selects, display it in the text box, and set it equal to a
variable. I know it has to use a file system object, but
I don't know where to go from there. Any help/code would
be appreciated.

-Brad

Tom Ogilvy

Adding browse button to userform
 
Private Sub CommandButton1_Click()
Dim fName as String
fName = Application.GetOpenFileName()
if not fName = "False" then
Textbox1.Value = fName
End if
end Sub


See Excel VBA help on Application.GetOpenFilename for options such as
filetype.

Use Chdrive and Chdir to start at a specific location.

--
Regards,
Tom Ogilvy


"Brad" wrote in message
...
Hi all,

I'm trying to add a browse button to a custom userform.
The goal is to capture the path and filename the user
selects, display it in the text box, and set it equal to a
variable. I know it has to use a file system object, but
I don't know where to go from there. Any help/code would
be appreciated.

-Brad





All times are GMT +1. The time now is 06:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com