从记事本/文本导入数据时如何保持空格

时间:2019-04-25 17:29:52

标签: vba text notepad

我正在从文本文件中将数据导入excel,但是导入时间距会改变。如何编码以保持与文本文件相同的间距。基本上,我将使用此间距将文本转换为列。 文本文件enter image description here

导入到excel enter image description here

Sub Macro1()
'
' Macro1 Macro
'

'
    Sheets.Add After:=Sheets(Sheets.Count)
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;C:\Users\1538544\Desktop\CIB\3\1114744500_A0000076849_SOIL.txt", _
        Destination:=Range("$A$1"))
        .Name = "1114744500_A0000076849_SOIL"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .TextFilePromptOnRefresh = False
        .TextFilePlatform = 932
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(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
End Sub

0 个答案:

没有答案