Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload File 3

Status
Not open for further replies.

bdmangum

Technical User
Dec 6, 2006
171
US
I'm not certain if this is possible using VBA. What I would like to do is give the user the ability to upload a file into a folder using a userform. I know I can have the user input the file path, where I can then copy the file. However I'd like to create the form so the user selects a commandbutton which opens a window similar to the typical save/open window.

The user needs to be able to browse their pc for the file. I know how to do it the long complicated way (create a user form and use code to fill it with all the system folders/subfolders/files), but does anyone know an easier way to accomplish this? Is there a command which opens a window where the user selects the file and the command returns the file path?

Thanks in advance!

BD
 
Application.GetOpenFilename() Displays a file open window and returns the path and name of whatever file the user selects
 
Which application ?
If Excel you may consider the GetOpenFilename or GetSaveAsFilename methods.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Here's an example of this I recently used:

Code:
Private Sub cmdBrowse_Click()

Dim fd As FileDialog

Set fd = Application.FileDialog(msoFileDialogFilePicker)

txtFilename.SetFocus
With fd
    .Filters.Clear
    .Filters.Add "Excel Workbook", "*.xls"
    .AllowMultiSelect = False
    .InitialFileName = txtFilename.Text
    .Title = "Select import file"
End With
If fd.Show Then
    txtFilename.Text = fd.SelectedItems(1)
    cmdBrowse.SetFocus
End If
End Sub
 
Thanks guys! Those methods do exactly waht I need to do. I'm not sure why it didn't occur to me to use the GetOpenFilename or GetSaveAsFilename as I've used those commands many times!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top