After some quick testing, I think I have found the issue. You need to be sure you are not passing in the string "strFile" into the connection, and you need to concatenate the TEXT to the connection string. This is demonstrated here:
strFile = Application.GetOpenFilename 'Workbooks.Open strFile
strFile = "TEXT;" & strFile 'Add the TEXT; to beginning of connection string
With ActiveSheet.QueryTables.Add(Connection:= _
strFile, Destination _
:=Range("$A$1"))
... 'Remainder of code
End With
For good measure, you may want to put the With ActiveSheet.QueryTables.Add ... code inside an IF statement that checks to make sure a file was selected.
For example:
Dim strFile As String
strFile = Application.GetOpenFilename 'Workbooks.Open strFile
strFile = "TEXT;" & strFile
If strFile <> False Then
With ActiveSheet.QueryTables.Add(Connection:= _
strFile, Destination _
:=Range("$A$1"))
... 'Remainder of code
End With
Else
MsgBox "No file was selected!"
End If
Connection:="strFile"isConnection:=strFile