AW: CSV Import
22.10.2009 19:21:44
Tino
Hallo,
kannst ja mal testen.
Sub Makro2()
Dim sPfad As String
Dim oQuery As QueryTable
If Dir("C:\temp", vbDirectory) "" Then
ChDrive "C:"
ChDir "C:\temp"
sPfad = Application.GetOpenFilename("CSV Files (*.csv), *.csv")
If sPfad CStr(False) Then
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" & sPfad, Destination:=Range("A1"))
.Name = "CSV-Import"
.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(2, 2, 2, 2, 2, 2, 2, 2, 2, 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
For Each oQuery In ActiveSheet.QueryTables
oQuery.Delete
Next oQuery
With Rows("1:1")
.Font.Bold = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Cells.Columns.AutoFit
Range("A1").Select
End If
Else
MsgBox "Der Pfad 'C:\temp' wurde nicht gefunden!", vbCritical
End If
End Sub
Gruß Tino