I have a bit of code which usually opens up an ADODB connection, runs some sql and then returns the data to excel.
This works perfectly in 1 workbook, however when I copied over the code to a new workbook it is falling down right at the start giving me the message 'user-defined type not defined'
This is the beginning of the code
and it falls down on the line 'Dim cnn As ADODB.Connection'
Any idea why this might be?
This works perfectly in 1 workbook, however when I copied over the code to a new workbook it is falling down right at the start giving me the message 'user-defined type not defined'
This is the beginning of the code
Code:
Sub myConnection()
Dim cnn As ADODB.Connection
Dim MyRecordSet As ADODB.Recordset
Dim SqlString As String
Set cnn = New ADODB.Connection
and it falls down on the line 'Dim cnn As ADODB.Connection'
Any idea why this might be?