问题引用临时未保存的工作簿 - 运行时错误438

时间:2013-10-01 10:12:13

标签: excel vba excel-vba

我遇到一个问题是能够在临时工作簿上运行宏,这是错误的行:

With ActiveSheet.QueryTables.Add(Connection:= _
        "FilePath;", _
        Destination:=temp.Range("$A$1"))

这段代码显示运行时错误。我尝试过其他技术,例如readOnly,但它们也没有用。

这个问题有解决办法吗?

Sub temp()

Dim Qa As Workbook
Dim temp As Workbook
Dim sum As Worksheet
Dim cov As Worksheet
'Dim ClientDate1 As Date
'Dim ClientDate2 As Date
'Dim Url As String
'Dim FilePath As String

Set Qa = ThisWorkbook
Set temp = Workbooks.Add
Set sum = Qa.Worksheets("Summary")
Set cov = Qa.Worksheets("Coverage")
ClientName = sum.Range("A1")
ClientDate = sum.Range("A3").Value
ClientDate1 = Format(ClientDate, "mm")
ClientDate2 = Format(ClientDate, "yyyy")

Url = "http://" & "wiki.rosslyn.local/mediawiki/index.php/"
FilePath = Url & ClientName & "_" & ClientDate2 & "_" & ClientDate1

With ActiveSheet.QueryTables.Add(Connection:= _
        "FilePath;", _
        Destination:=temp.Range("$A$1"))
        .Name = "Deloitte_2013_08"
        .CommandType = 0
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False

    End With

  temp.Close

    End Sub

1 个答案:

答案 0 :(得分:0)

礼貌James Cone

  

从ClientName周围删除引号。

     

从......

 "Url" & "ClientName" &  
     

要......

 "Url" & ClientName &  
'---