Option
Explicit
Public
Sub
test()
Dim
vntReturn
As
Variant
vntReturn = Application.GetOpenFilename(FileFilter:=
"Text Files (*.csv),*.csv"
, _
Title:=
"Please select text file..."
)
If
vntReturn =
False
Then
Exit
Sub
With
ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;"
&
CStr
(vntReturn), Destination:= _
Range(
"$E$5"
))
.Name =
"csvTest_1"
.FieldNames =
True
.RowNumbers =
False
.FillAdjacentFormulas =
False
.PreserveFormatting =
True
.RefreshOnFileOpen =
False
.RefreshStyle = xlInsertDeleteCells
.SavePassword =
False
.SaveData =
True
.AdjustColumnWidth =
True
.RefreshPeriod = 0
.TextFilePromptOnRefresh =
False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter =
False
.TextFileTabDelimiter =
True
.TextFileSemicolonDelimiter =
True
.TextFileCommaDelimiter =
False
.TextFileSpaceDelimiter =
False
.TextFileColumnDataTypes = Array(1, 1, 1)
.TextFileTrailingMinusNumbers =
True
.Refresh BackgroundQuery:=
False
End
With
End
Sub