Sub
Import()
Dim
ImportDatei
As
String
Dim
readfile
As
String
ImportDatei = Application.GetOpenFilename(FileFilter:=
"Text Files (*.txt), *.txt"
, Title:=
"Eine Datei auswählen"
)
readfile = Right(ImportDatei, Len(ImportDatei) - InStrRev(ImportDatei, "\"))
Sheets(
"XXXX"
).
Select
Cells.
Select
Selection.ClearContents
Cells(1, 1).
Select
With
ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;"
+ ImportDatei _
, Destination:=Range(
"A1"
))
.Name = readfile
.FieldNames =
True
.RowNumbers =
False
.FillAdjacentFormulas =
False
.PreserveFormatting =
True
.RefreshOnFileOpen =
False
.RefreshStyle = xlInsertDeleteCells
.SavePassword =
False
.SaveData =
True
.AdjustColumnWidth =
True
.RefreshPeriod = 0
.TextFilePromptOnRefresh =
False
.TextFilePlatform = 65001
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter =
False
.TextFileTabDelimiter =
True
.TextFileSemicolonDelimiter =
False
.TextFileCommaDelimiter =
False
.TextFileSpaceDelimiter =
False
.TextFileOtherDelimiter = "\"
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 _
, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers =
True
.Refresh BackgroundQuery:=
False
End
With
Rows(
"2:2"
).
Select
Selection.Delete Shift:=xlUp
End
Sub