在宏中使用相对路径

时间:2017-07-03 12:54:10

标签: excel excel-vba vba

我正在编辑一个宏,以便它将数据连接路径更新为相对,但我收到错误。

你能帮我调试一下吗? 错误发生在我添加工作簿路径的行上。

谢谢 Ĵ

    ' UpdateDataConnectionQuery Macro
'

'
    With ActiveWorkbook.Connections("Model Metrics")
        .Name = "Model Metrics"
        .Description = ""
    End With
    Range("A2:K51").Select
    With Selection.QueryTable
        .Connection = _
       ThisWorkbook.Path & "TEXT;\Models\Model Metrics.txt"
        .CommandType = 0
        .TextFilePlatform = 850
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = True
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = False
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With
    Range("R38").Select

0 个答案:

没有答案