title: How can I resolve this error message "Compile Error: User-defined type not defined" in Microsoft VBA
body: <p>I am new at Microsoft-VBA, and i trying to make Excel run a Stored Procedure in MSSQL Server and add the records to a table created for that purpose. But every time i try to run this to test my code, i get this error message. I have reviewed and implemented some solutions suggested on this forum, but i have not been able to make it work. For example, i have gone to activate the 'Microsoft ActiveX Data Objects Recordset 2.8 Library in Tools > References, but i still get the same error. Will be glad if anybody can review my code and tell me what i am doing wrong.</p>
  
  <p><a href="https://i.stack.imgur.com/4bA72.png" rel="nofollow noreferrer">This image contains the code and error message</a></p>
  
  <hr>
  
  <pre><code>Sub My_Test_Report()
  
      Dim objConn As New ADODB.Connection
      Dim objCmd As New ADODB.Command
      Dim objParm1 As New ADODB.Parameter
      Dim objRs As New ADODB.Recordset
  
      objCmd.CommandText = "[Report Queries].[dbo].[My_Test_Report]"
      objCmd.CommandType = adCmdStoredProc
      Set objConn = GetNewConnection
      objCmd.ActiveConnection = objConn
      objCmd.Parameters.Refresh
      objCmd(1) = True
      Set objRs = objCmd.Execute
  
  End Sub
  </code></pre>