Erreur 429 un composant active x ne peut pas créer d'objet
n
Bonjour j'ai un soucis avec mon code...
j'ai bien la référence microsoft activex data object 2.8 library
j'ai bien l'accès approuvé au modèle d'objet du projet VBA
Public cnx As New ADODB.Connection
'------------------------------------------
Sub creertable()
Dim rsx As New ADODB.Recordset
'macro créer pour report le pointage hebdo vers access
Dim semaine%, num_colonne%, str$, txt$, x%
semaine = Right(Left(ThisWorkbook.Name, 17), 2)
On Error GoTo lastline:
'Définition du pilote de connexion en fonction de la version office
cnx.Provider = "Microsoft.ACE.OLEDB.12.0"
'Définition de la chaîne de connexion
cnx.ConnectionString = "C:\Users\naubin\Desktop\grilledepolyvalence1.accdb"
'Ouverture de la base de données
cnx.Open
cnx.Execute "DROP TABLE S" & semaine
create:
cnx.Execute "CREATE TABLE [S" & semaine & "](ID integer ," & _
"Nom_Prénom TEXT)" '& _
" FOREIGN KEY(ID) REFERENCES liste_salarie(identifiant_salarie))"
With Sheets("Pointage")
cnx.Execute "ALTER TABLE [S" & semaine & "]" & _
"ADD COLUMN Absences TIME," & _
" RemplacementSUP TIME," & _
" VisiteMedical TIME"
cnx.Execute "ALTER TABLE [S" & semaine & "]" & _
" ADD COLUMN Logistique TIME," & _
" Délégation TIME"
txt = "Select Identifiant_salarié , NOM_PRENOM " & _
"From [Liste personnel]" '& _
"Where 'P" & poste & " Between '" & hab & "' And '10'"
rsx.Open txt, cnx
.Unprotect "plac@18"
While Not rsx.EOF
For x = 30 To .Range("WZ30").End(xlDown).Row - 1
If .Cells(x, 624).Value = rsx.Fields("NOM_PRENOM") Then
.Cells(x, 623).Value = rsx.Fields("Identifiant_salarié")
Exit For
End If
Next x
rsx.MoveNext
Wend
.Protect "plac@18"
For x = 30 To .Range("WZ30").End(xlDown).Row - 1
If .Cells(x, 623) = "0" Or .Cells(x, 623) = "" Then
Else
str = "INSERT INTO S" & semaine & " VALUES (" & .Cells(x, 623) & ",'" & .Cells(x, 624) & _
"','" & Format(.Cells(x, 625), "hh:mm:ss") & "','" & Format(.Cells(x, 626), "hh:mm:ss") & "','" & _
Format(.Cells(x, 627), "hh:mm:ss") & "','" & Format(.Cells(x, 628), "hh:mm:ss") & "','" & _
Format(.Cells(x, 629), "hh:mm:ss") & "','" & Format(.Cells(x, 630), "hh:mm:ss") & "','" & _
Format(.Cells(x, 631), "hh:mm:ss") & "','" & Format(.Cells(x, 632), "hh:mm:ss") & "','" & _
Format(.Cells(x, 633), "hh:mm:ss") & "','" & Format(.Cells(x, 634), "hh:mm:ss") & "','" & _
Format(.Cells(x, 635), "hh:mm:ss") & "','" & Format(.Cells(x, 636), "hh:mm:ss") & "','" & _
Format(.Cells(x, 637), "hh:mm:ss") & "','" & Format(.Cells(x, 638), "hh:mm:ss") & "','" & _
Format(.Cells(x, 639), "hh:mm:ss") & "','" & Format(.Cells(x, 640), "hh:mm:ss") & "','" & _
Format(.Cells(x, 641), "hh:mm:ss") & "','" & Format(.Cells(x, 642), "hh:mm:ss") & "','" & _
Format(.Cells(x, 643), "hh:mm:ss") & "','" & Format(.Cells(x, 644), "hh:mm:ss") & "','" & _
Format(.Cells(x, 645), "hh:mm:ss") & "','" & Format(.Cells(x, 646), "hh:mm:ss") & "','" & _
Format(.Cells(x, 647), "hh:mm:ss") & "','" & Format(.Cells(x, 648), "hh:mm:ss") & "','" & _
Format(.Cells(x, 649), "hh:mm:ss") & "','" & Format(.Cells(x, 650), "hh:mm:ss") & "','" & _
Format(.Cells(x, 651), "hh:mm:ss") & "','" & Format(.Cells(x, 652), "hh:mm:ss") & "','" & _
Format(.Cells(x, 653), "hh:mm:ss") & "','" & Format(.Cells(x, 654), "hh:mm:ss") & "','" & _
Format(.Cells(x, 655), "hh:mm:ss") & "','" & Format(.Cells(x, 656), "hh:mm:ss") & "','" & _
Format(.Cells(x, 657), "hh:mm:ss") & "','" & Format(.Cells(x, 658), "hh:mm:ss") & "','" & _
Format(.Cells(x, 659), "hh:mm:ss") & "')"
cnx.Execute str, dbFailOnerror
End If
Next x
End With
Set rsx = Nothing
Set cnx = Nothing
Exit Sub
lastline:
'cnx.Execute "DROP TABLE S" & semaine
If Err.Number = -2147217865 Then GoTo create
If Err.Number = -2147217900 Then
If MsgBox("La table S" & semaine & " existe déjà voulez vous la remplacer?", vbYesNo, " &" _
& "Demande de confirmation") = vbYes Then
cnx.Execute "DROP TABLE S" & semaine
GoTo create
End If
End If
MonResultat = MsgBox("Erreur n° " & Err.Number & vbCrLf & "Description : " & Err.Description & " call N.A ", vbCritical + vbOKOnly, "Erreur d'execution")
Set rsx = Nothing
Set cnx = Nothing
End Sub
L
Sur quelle ligne ce manifeste l'erreur ?
n
Bonjour,
depuis le début de l’exécution du code, a la première ligne déjà il me met le problème
L
Quelle et le type de votre variable semaine ?