我在临时工作簿上运行宏时遇到问题,这是错误行:
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