에 오류 :VBA의 나는 다음과 같은 코드를 엑셀
Sub Stats1()
Workbooks("2006_2007_2008.xls").Sheets("Sheet1").Select
Worksheets("Sheet1").Activate
Dim my_cell As String
my_cell = InputBox("Which cell?")
Dim objConn As ADODB.Connection
Dim rsData As ADODB.Recordset
Dim strSQL As String
Dim mycell As String
szconnect = "Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=*****;Data Source=*****"
'Create the Connection and Recordset objects.
Set objConn = New ADODB.Connection
Set rsData = New ADODB.Recordset
On Error GoTo errHandler
'Open the Connection and execute the stored procedure
objConn.Open szconnect
strSQL = "SELECT *fom mytable"
objConn.CommandTimeout = 0
Set rsData = objConn.Execute(strSQL)
For iCols = 0 To rsData.Fields.Count - 1
ActiveSheet.Range(my_cell).Select
ActiveSheet.Cells(ActiveCell.Row, ActiveCell.Column + iCols).Value = rsData.Fields (iCols).Name
ActiveSheet.Cells.Font.Name = "Arial"
ActiveSheet.Cells.Font.Size = 8
Next
ActiveSheet.Range(ActiveSheet.Cells(ActiveCell.Row, ActiveCell.Column), ActiveSheet.Cells(ActiveCell.Row, ActiveCell.Column + rsData.Fields.Count)).Font.Bold = True
If Not rsData.EOF Then
'Dump the contents of the recordset onto the worksheet
On Error GoTo errHandler
ActiveSheet.Cells(ActiveCell.Row, ActiveCell.Column).CopyFromRecordset rsData
If Not rsData.EOF Then
MsgBox "Data set too large for a worksheet!"
End If
rsData.Close
End If
Unload frmSQLQueryADO
Exit Sub
errHandler:
MsgBox Err.Description, vbCritical, "Error No: " & Err.Number
'Unload frmSQLQueryADO
End Sub
내가 "424 필요한 개체 오류"좀 .. 그나마 문제가 무엇인지 ...! 는 내가 모든 올바른 참조
을 추가 한 생각
__VAB__ in excel. 오타입니까? –
어떤 라인에서 오류가 발생합니까? –
나는 잘 모르겠다. 프로그램이 잘 실행된다.., 나는 결과로부터 질의를 얻고, 결국에는 오류를 얻는다. ... 나는 디버그를하지 않는다. 아무 것도 얻지 못한다 .... – andreas