VBA连接导入-更改导入连接

时间:2018-11-13 21:48:17

标签: excel vba excel-vba connection

我不确定这里缺少什么,但是由于某些原因,当我将CSV文件导入excel时,很难定义连接名称。我有一个单元格,它直接位于应该作为连接名称的导入数据上方的两行。由于某些原因,在输入数据后,连接名称仍由文件名设置,而不是由“ MyInput”数据中定义的值设置。我想念什么?

Sheets("CSV - Session Data").Range("A100000").End(xlUp) = MyInput

With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & FileName, Destination:=Sheets("CSV - Session Data").Range("A100000").End(xlUp).Offset(2, 0))
    .Name = MyInput
    .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 = True
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
End With

谢谢

标记

0 个答案:

没有答案