Experts Exchange connects you with the people and services you need so you can get back to work.
Public Function SelectFile() As String
'Requires Office XP (2002) or higher
'Requires a reference to the Microsoft Office Object Library
'Created by Helen Feddema 28-Oct-2012
'Last modified by Helen Feddema 28-Oct-2012
On Error GoTo ErrorHandler
Dim fd As Office.FileDialog
Dim varSelectedItem As Variant
Dim strFileNameAndPath As String
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Set AllowMultiSelect to True to allow selection of multiple files
.AllowMultiSelect = False
.Title = "Browse for File"
.ButtonName = "Select"
.Filters.Add "Documents", "*.xlsx; *.xlsm", 1
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
'Get selected item in the FileDialogSelectedItems collection
'Have to use collection even if just one item is selected
For Each varSelectedItem In .SelectedItems
strFileNameAndPath = CStr(varSelectedItem)
Debug.Print "User pressed Cancel"
strFileNameAndPath = ""
SelectFile = strFileNameAndPath
Set fd = Nothing
MsgBox "Error No: " & Err.Number _
& " in SelectFile procedure; " _
& "Description: " & Err.Description
Open in new window
On Error GoTo errHere
Dim strQRY As String
Dim strHTTP As String
Dim strFileToSave As String
strHTTP = "https://asfr.hhh.net/OF/OFSPO/hhsfmg/mwwg/Data%20Call%20%20DDA/2016%20September%20DDA%20Data%20Call.xlsx"
strFileToSave = "C:\Users\shieldsco\Documents\Vince.xlsx"
If fnDownloadHTTP(strHTTP, strFileToSave) = False Then ' -- downlaod the file
MsgBox "File DL failed. Make sure folder exist"
MsgBox "All files downloaded"
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
strHTTP = "https://asfr.hhh.net/OF/OFSPO/hhsfmg/mwwg/Data%20Call%20%20DDA/2016%20September%20DDA%20Data%20Call.xlsx
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.
Premium members get this course for $174.99.
Premium members get this course for $389.00.
Premium members get this course for $79.20.
Premium members get this course for $159.20.
Premium members get this course for $148.75.
Premium members get this course for $62.50.