我有这段代码试图查询ms sql数据库,但是在最后一行得到上述错误,请帮忙
'Declare variables'
Dim objMyConn As ADODB.Connection
Dim objMyRecordset As ADODB.Recordset
Set objMyConn = New ADODB.Connection
Set objMyRecordset = New ADODB.Recordset
Dim strSQL As String
'Open Connection'
objMyConn.ConnectionString = "connection string"
objMyConn.Open
'Set and Excecute SQL Command'
strSQL = "SELECT * FROM dbtable"
'Open Recordset'
Set objMyRecordset.ActiveConnection = objMyConn
objMyRecordset.Open strSQL
'Copy Data to Excel'
(ERROR HERE-->) ActiveSheet.Range("A1").CopyFromRecordset (objMyRecordset)