制表符分隔值的宏

时间:2015-09-23 20:18:27

标签: excel vba excel-vba

我正试图直接获得一个宏,我这是第一次这样做。我有一个宏,当我运行它来导入.tsv文件列不是预期的,值被放在其他列中。显然相同的文件用于正常运行,但有人意外地改变了一些东西。

Sub Macro2()
sLocalFile = "C:myPath\myFile.tsv"
        With ActiveSheet.QueryTables.Add(Connection:= _
            "TEXT;" & sLocalFile, Destination:=ActiveSheet.Range("$A$1"))
            .Name = "SomeName"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .RefreshStyle = xlOverwriteCells
            .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
            .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)
            .TextFileTrailingMinusNumbers = True
            .Refresh BackgroundQuery:=False
        End With

End Sub 

0 个答案:

没有答案