title: Excel Macro Error - "User Defined Type Not Defined" - References Grayed out
body: <p>So I created this code (probably don't even have to show it- but just in case!), have not been able to test it as I get "User defined type not defined" on the first line. I saw that I should set the reference in Tools>References but
  the option is grayed out....        </p>
  
  <pre><code>Sub UploadDistributors()
  Dim cnn As ADODB.Connection
  Dim rs As ADODB.Recordset
  Set cnn = New ADODB.Connection
  Set rs = New ADODB.Recordset
  
  strConn = "Provider=SQLOLEDB-Removed for security-Network Library=DBMSSOCN"
  
  cnn.Open strConn 
  
  Dim k
  k = 0
  
     For i = 1 To 352
  
     sSQL = "INSERT INTO DistributorsNP (CompanyName, address, city, state, zip, phone,    tollfree) VALUES ("
  
      'CompanyName
      sSQL = sSQL &amp; Sheet1.Range("B" &amp; i).Value &amp; ","
      'address
      sSQL = sSQL &amp; Sheet1.Range("C" &amp; i).Value &amp; ","
      'city
      sSQL = sSQL &amp; Sheet1.Range("D" &amp; i).Value &amp; ","
      'state
      sSQL = sSQL &amp; Sheet1.Range("E" &amp; i).Value &amp; ","
      'zip
      sSQL = sSQL &amp; Sheet1.Range("F" &amp; i).Value &amp; ","
      'phone
      sSQL = sSQL &amp; Sheet1.Range("G" &amp; i).Value &amp; ","
      'tollfree
      sSQL = sSQL &amp; Sheet1.Range("H" &amp; i).Value &amp; ","
  
  
  
  sSQL = sSQL &amp; ")"
  rs.Open sSQL, cnn, adOpenStatic, adLockReadOnly, adCmdText
  
  rs.Close
  
  Next
  
  End Sub
  </code></pre>