想以巨集擷取外部資料,錄製以下動作:
資料->現有連線->選取iqy檔->選擇儲存格位置->停止錄製
結果重新執行時出現以下錯誤訊息:
執行階段錯誤'5'
程序呼叫或引數不正確
究竟是哪出錯了?
附上程式碼
Sub 巨集1()
'
' 巨集1 巨集
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\Users\jamesle\Desktop\TTTTFFFF.iqy",
Destination:=Range("$A$1"))
.CommandType = 0
.Name = "TTTTFFFF"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """tb"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub