本帖最后由 290706123@qq.com 于 2012-8-25 11:24 編輯
- Set Quert = oETSheet.QueryTables.Add("TEXT;" & sPath, oET.Range("A1"))
復(fù)制代碼 這句代碼執(zhí)行時(shí)報(bào)錯(cuò)“實(shí)時(shí)錯(cuò)誤5,無(wú)效的過(guò)程調(diào)用或參數(shù)”
我傳遞的參數(shù)么有問(wèn)題呀,應(yīng)該是這個(gè)接口內(nèi)部出現(xiàn)了問(wèn)題,請(qǐng)ET研發(fā)人員盡快修正
這里附上代碼全文- Private Sub ETInputCSV()
- Dim oET As Object
- Dim oETSheet As Object
- Dim Quert As Object
- Dim sPath As String
- Set oET = CreateObject("ET.Application")
- sPath = ""
- sPath = oET.GetOpenFilename("待導(dǎo)入文件CSV,*.csv", 1, "打開(kāi)需要導(dǎo)入的文件", "導(dǎo)入", False)
- If UCase(sPath) = UCase("False") Then
- oET.Quit
- Set oET = Nothing
- Exit Sub
- End If
- oET.SheetsInNewWorkbook = 1
- With oET.Workbooks.Add()
- .Activate
- End With
- Set oETSheet = oET.ActiveSheet
- If oETSheet Is Nothing Then
- Set oETSheet = oET.ActiveWorkbook.Worksheets.Add
- End If
- oETSheet.Name = "導(dǎo)入"
- Set Quert = oETSheet.QueryTables.Add("TEXT;" & sPath, oETSheet.Cells(0, 0))
- With Quert
- .Name = "Path"
- .FieldNames = True '字段名稱作為返回?cái)?shù)據(jù)的列標(biāo)題顯示
- .RowNumbers = False '不允許顯示行號(hào)
- .FillAdjacentFormulas = False '自動(dòng)刷新數(shù)據(jù)源
- .PreserveFormatting = True
- .RefreshOnFileOpen = False '每次打開(kāi)文件時(shí)自動(dòng)刷新數(shù)據(jù)源
- .RefreshStyle = xlInsertDeleteCells '更新方式:插入或者刪除部分行以適應(yīng)新記錄集所需要的實(shí)際行數(shù)
- .SavePassword = False '是否保存查詢密碼
- .SaveData = True
- .AdjustColumnWidth = True '自動(dòng)調(diào)整列寬
- .RefreshPeriod = 0 '刷新間隔
- .TextFilePromptOnRefresh = False
- .TextFilePlatform = 936 '被導(dǎo)入文件的代碼頁(yè)
- .TextFileStartRow = 1 '導(dǎo)入文本文件時(shí)進(jìn)行文本分列的起始行號(hào)
- .TextFileParseType = xlDelimited '導(dǎo)入查詢表的文本文件中數(shù)據(jù)的列格式
- .TextFileTextQualifier = xlTextQualifierDoubleQuote '設(shè)置導(dǎo)入文件的列分隔符類型。這里選擇是,加雙引號(hào)
- .TextFileConsecutiveDelimiter = False '不將連續(xù)分隔符看作是一個(gè)分隔符
- .TextFileTabDelimiter = False '導(dǎo)入文本文件時(shí)不使用 Tab 作為分隔符
- .TextFileSemicolonDelimiter = False '導(dǎo)入文本文件時(shí)不使用分號(hào)作為分隔符
- .TextFileCommaDelimiter = True '導(dǎo)入查詢表中時(shí),以逗號(hào)作為分隔符
- .TextFileSpaceDelimiter = False '導(dǎo)入文本文件時(shí),使用空格字符作為分隔符
- .TextFileColumnDataTypes = Array(2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2) '設(shè)置所有列的格式,使用類型是 xlcolundatatype 這里全部設(shè)置為 xlTxtFormat=2 就是文本
- .TextFileTrailingMinusNumbers = True '數(shù)字是否使用負(fù)號(hào)
- .Refresh BackgroundQuery:=False
- End With
- oET.Visible = True
- End Sub
復(fù)制代碼 |
|