I'm working on getting SQL into Excel using vba with the following script (censored to protect some db info, however the parts of the script work) When I go to compile I get the Run Time Error 430: Class Does not support Automation or does not support expected interface
I am using Excel 2007, VBA 6.5 and SQL 2005
Here's the script
Sub GetDataFromADO()
Dim objMyConn As ADODB.Connection
Dim objMyCmd As ADODB.Command
Dim objMyRecordset As ADODB.Recordset
Set objMyConn = New ADODB.Connection
Set objMyCmd = New ADODB.Command
Set objMyRecordset = New Recordset
objMyConn.ConnectionString = "Provider=SQLOLEDB;SERVER=M$#$%#@@$1;DATABASE=i*&^*;Trusted_Connection=yes;HDR=yes"
objMyConn.Open
Set objMyCmd.ActiveConnection = objMyConn
objMyCmd.CommandText = "use i*&^* select * from $#%.^&_d**^%_p**^^l where year(d****_date) = 2012 and month(d***_date)= 03 and deal_id < 5*******0 order by d***_id"
objMyCmd.CommandType = adCmdText
objMyCmd.Execute
ActiveSheet.Range("A2").CopyFromRecordset (objMyRecordset)
End Sub