I'm using VBA in Excel 2013 to do something that shouldn't be hard. I want the user to be able to choose a file. When I open I dialog box to choose the file, and then try to open the file, I get a Runtime 1004 error "Sorry, we could find <filename>. Is it possible it was moved, renamed, or deleted?" However, when I hard code workbooks.open <filename with path> it opens fine. Here is the code to prompt for the file:

Sub GetImportFileName2(spath, UFileName)
Dim Filt As String
Dim FilterIndex As Integer
Dim FileName As Variant
Dim Title As String
Dim i As Integer
Dim Msg As String
' Set up list of file filters
Filt = "Text Files (*.txt),*.txt," & _
"Comma Separated Files (*.csv),*.csv," & _
"Excel Files (*.xlsx),*.xlsx," & _
"All Files (*.*),*.*"
' Display *.xlsx by default
FilterIndex = 4
' Set the dialog box caption
Title = "Select a file to open:"
' Get the file name
FileName = Application.GetOpenFilename _
(FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title, _
MultiSelect:=True)
' Exit if dialog box canceled
If Not IsArray(FileName) Then
MsgBox "No file was selected."
Exit Sub
End If
' Display full path and name of the files
For i = LBound(FileName) To UBound(FileName)
Msg = Msg & FileName(i) & vbCrLf
Next i
spath = Left(Msg, InStrRev(Msg, "\"))
MsgBox "Path: " & spath
UFileName = Mid(Msg, InStrRev(Msg, "\") + 1)
MsgBox "File: " & UFileName
End Sub

As you can see I have inserted a bunch of MsgBox calls so I can check the path and filename. Everything is fine. Then I do:

Workbooks.Open spath & UFileName

And I get the error (the path and filename shown in the error dialog box as not being found is the correct path and filename, so I'm concatenating fine). However, if I just do:

Workbooks.Open FileName:="path and filename exactly as it shows in the error message"

The file opens fine.

Thanks for listening :-)