Your technology certification is waiting. Enroll in Cloud Class ®
Public Function SelectFile() As String
'Requires Office XP (2002) or higher
'Requires a reference to the Microsoft Office Object Library
'Created by Helen Feddema 3-Aug-2009
'Last modified 3-Aug-2009
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", "*.doc; *.txt", 1
.InitialView = msoFileDialogViewDetails
If .Show = -1 Then
'Get selected item in the FileDialogSelectedItems collection
For Each varSelectedItem In .SelectedItems
strFileNameAndPath = CStr(varSelectedItem)
Debug.Print "User pressed Cancel"
strFileNameAndPath = ""
SelectFile = strFileNameAndPath
Me![txtFileName].value = strFileNameAndPath
Set fd = Nothing
MsgBox "Error No: " & Err.Number _
& " in SelectFile procedure; " _
& "Description: " & Err.Description
Open in new window
Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
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.