I have the following in my DB and it works as long a s the line .InitialFileName is a hard coded string. I would however like to be able to pass a variable to the function that hones in on the proper directory a little closer. I'm tryin g to pass a variable and use it in .InitialFileName= Any one know if/How to do this???
Public Function fGetPath(Optional vStartFolder As String) As String
Dim f As Object
Dim strFile As String
Dim strFolder As String
Dim varItem As Variant
Dim strStartFolder As String
strStartFolder = vStartFolder
strStartFolder = "C:\Users\bbrazeau\Desktop\MyDB\" & strStartFolder
Set f = Application.FileDialog(3)
MsgBox (strStartFolder)
With f
.InitialFileName = "C:\Users\bbrazeau\Desktop\MyDB\"
f.AllowMultiSelect = True
If f.Show Then
For Each varItem In f.SelectedItems
strFile = Dir(varItem)
strFolder = Left(varItem, Len(varItem) - Len(strFile))
MsgBox "Folder: " & strFolder & vbCrLf & _
"File: " & strFile
fGetPath = varItem
Next
End If
End With
Set f = Nothing
End Function