[VBA-E]connection ADO, pq ca plante?
Bonjour
Je suis en train de faire une feuille excell modèle pour exporter ces données dans une base de donnée access. J'essaie de me connecter à ma base de donnée mais je n'y arrive pas.
J'ai retapé l'exemple de la doc de VB pour Excell mais ca plante :
Voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Option Explicit
Private Sub Workbook_Open()
Dim cnnConn As ADODB.Connection
Dim rstRecordset As ADODB.Recordset
Dim cmdCommand As ADODB.Command
' Open the connection.
Set cnnConn = New ADODB.Connection
With cnnConn
.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0"
.Open "C:\perfdate\record.mdb"
End With
' Set the command text.
Set cmdCommand = New ADODB.Command
Set cmdCommand.ActiveConnection = cnnConn
With cmdCommand
.CommandText = "Select Speed, Pressure, Time From DynoRun"
.CommandType = adCmdText
.Execute
End With
' Open the recordset.
Set rstRecordset = New ADODB.Recordset
Set rstRecordset.ActiveConnection = cnnConn
rstRecordset.Open cmdCommand
End Sub |
En fait je compile et il m'affiche :
User-defined type not defined
pour la ligne :
Code:
Dim cnnConn As ADODB.Connection
Je ne comprends pas pourquoi il ne reconnait pas ADODB :roll:
Config : Visual Basic 6.0 Access 2003 Excel 2003 Windows XP pro
Pourriez vous m'aider. Merci d'avance.