The other way is to not use references at all and use what is known as LATE BINDING. The code modified to use Late Binding would be:
Code:
Private Sub GetfileName(SelectedFile, usercanceled As Boolean, Section As String, tFileDescription)
' This requires a reference to the Microsoft Office 11.0 Object Library.
Dim fDialog As Object
Dim varFile As Variant
Dim Const msoFileDialogFilePicker As Integer = 3
' Set up the File dialog box.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Don't Allow the user to make multiple selections in the dialog box.
.AllowMultiSelect = False
' Set the title of the dialog box.
.Title = tFileDescription
' Clear out the current filters, and then add your own.
.Filters.Clear
.Filters.Add "Excell Spreadsheets", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
' Loop through each file that is selected and then add it to the list box.
For Each varFile In .SelectedItems
SelectedFile = varFile
usercanceled = False
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
usercanceled = True
End If
End With
End Sub
The only drawback is that intellisense doesn't work with late binding. So I usually use early binding (by setting the reference) until I have it the way I want and then change over to late binding for production and then when versions change there is no issue.