[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