[VBA ] 錄製巨集結取外部資料失敗

作者: redmist (....N )   2013-08-02 13:37:34
想以巨集擷取外部資料,錄製以下動作:
資料->現有連線->選取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
作者: s06yji3 (阿南)   2013-08-06 06:44:00
根據我的經驗,可能是設定引用項目沒有設定好

Links booklink

Contact Us: admin [ a t ] ucptt.com