1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Sub AjoutEnregistrement()
repertoire = ThisWorkbook.Path & "\"
Set cnn = New ADODB.Connection
Fichier = repertoire & "ADOsource.xls"
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Fichier & ";Extended Properties=""Excel 8.0;HDR=YES; """
Dim cm As New ADODB.Command
With cm
.ActiveConnection = cnn
.CommandText = "INSERT INTO [Feuil1$] ([Nom],[Prénom],[texte]) Values (?,?,?)"
.CommandType = adCmdText
.Parameters.Append .CreateParameter("@Nom", adLongVarChar, adParamInput, 250, ThisWorkbook.Sheets("feuil1").Cells(2, 1))
.Parameters.Append .CreateParameter("@Prénom", adLongVarChar, adParamInput, 250, ThisWorkbook.Sheets("feuil1").Cells(2, 2))
.Parameters.Append .CreateParameter("@texte", adLongVarChar, adParamInput, 30000, ThisWorkbook.Sheets("feuil1").Cells(2, 3))
.Execute
End With
End Sub |
Partager