0
ADO 연결을 사용하여 닫힌 된 Excel 2007 통합 문서 (.xlsx)에서 데이터를 복사하려고합니다..xlsx 파일에 VBA ADO 연결
연결 문자열이 작동합니다. 하지만 레코드를 명령을 열려고 할 때 자동화 오류가 발생합니다 (마지막 줄에서 두 번째).
이 너무 아래 코드에서 명확하지 않을 수 있습니다
"wsSummary는"워크 시트 개체 이다 "strSourceFile는"내가 (예 : Template.xlsx)
복사해야 할 대상 데이터와 문자열strSourceFile = wsSummary.Cells(nFirstRow + 4, 7)
strSheetSource = "Sheet1"
strSQL = "SELECT * FROM [" & strSheetSource & "]"
Set dbConnection = New ADODB.Connection
With dbConnection
.Provider = "Microsoft.ACE.OLEDB.12.0;"
.connectionString = "Data Source=" & strPOINTDataPath & strSourceFile & _
";Extended Properties=""Excel 12.0 Xml;HDR=NO;IMEX=1"";"
.ConnectionTimeout = 40
.Open
End With
If dbConnection = "" Then GoTo ErrorText
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = dbConnection
.CommandText = strSQL
End With
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = dbConnection
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open cmd
End With
즉시 그것을 해결 주셔서 감사합니다 – GreenyMcDuff