Ecrire un code vba dans un checkbox

Fermé
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 - 13 janv. 2022 à 10:41
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 - 19 janv. 2022 à 09:51
Bonjour le forum
voila dans ma création de texbox et checkbox en dynamique je dois créer un code vba voici le code
j'ai une erreur sur l'objet
merci de votre aide
Set Obj = Liste_Freelance_periode.Controls.Add("forms.checkbox.1")

With Obj
.Name = "Eff_" & (NT + 1)
'.Object.Value = "Sjtc_" & (NT + 1)
.Left = ((10 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch + Lw + Ls)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Le
.Height = h
With Obj.VBProject.VBComponents _
("forms.checkbox.1").CodeModule
Code = "Private Sub Effacer_Click()" & vbCrLf
Code = Code & "If Effacer.Value = True Then" & vbCrLf
Code = Code & "Me.Nom_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Prenom_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Client_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Chiffre_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Marge_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Me.TJM_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Me.WOW_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Nbjrs_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Me.SJTC_1.BackColor = &HFF&" & vbCrLf
Code = Code & "Else" & vbCrLf

Code = Code & "Me.Nom_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Prenom_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Client_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Chiffre_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Marge_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.TJM_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.WOW_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Nbjrs_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.SJTC_1.BackColor = &HFFFFFF" & vbCrLf
Code = Code & "End If" & vbCrLf
Code = Code & "End Sub" & vbCrLf

With Obj.VBProject. _
VBComponents("forms.checkbox.1").CodeModule
.AddFromString LeTexte
NextLine = .CountOfLines + 1

.InsertLines NextLine, Code
End With
End With
End With
Set Cl = New Classe1
Set Cl.CheckBox = Obj
Collect.Add Cl

End With
Next NT
A voir également:

6 réponses

yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474
13 janv. 2022 à 13:17
bonjour,
quelle erreur sur quel objet?
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1
13 janv. 2022 à 13:49
Bonjour Yg-be,
alors cela me met une rreur 438 sur ce code
With Obj.VBProject.VBComponents _
("Eff_" & (NT + 1)).CodeModule

merci par avance
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474 > titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023
13 janv. 2022 à 13:58
Amusant, je ne vois pas ces lignes dans le code partagé.
Peux-tu aussi partager le texte de l'erreur, et utiliser les balises de code? Explications: https://codes-sources.commentcamarche.net/faq/11288-les-balises-de-code
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1 > yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024
13 janv. 2022 à 14:13
Re,
Jai pourtant utiliser le bouton code pour insérer le code .. c'est pas bon ?
voici le code entier de la sub

Sub Valider_Les_Dates_Click()
Dim LeTexte As Variant
Dim Code$, NextLine&
Dim cherche As Variant
Dim chercheF As Variant
Dim c As Variant
Dim d As Variant
Dim NT As Variant
Dim NR As Variant
Dim LL As Long
Dim Ln As Long
Dim Lp As Long
Dim Lc As Long
Dim Lnb As Long
Dim Lt As Long
Dim Lm As Long
Dim Lch As Long
Dim Lw As Long
Dim Ls As Long
Dim Le As Long
Dim h As Long
Dim Cl As Classe1
Dim Obj As Control
Dim Nts As Control
Dim montexte2 As Control
Dim premier As Variant
Dim Nbre_Free_Lance As Integer
Dim Nbre_Recru As Integer
Dim Nbre_Free_LanceT As Integer
Dim cell As Variant
Dim Debut_Facturation_M As Variant
Dim Fin_Facturation_M As Variant
Set Collect = New Collection
cherche = Me.Debut_Facturation_M & " " & Me.Debut_Facturationt_A
chercheF = Me.Fin_Facturation_M & " " & Me.Fin_de_Facturation_A
With Me.Debut_Facturation_M
If Me.Debut_Facturation_M = "janvier" Then
Debut_Facturation_M = 1
ElseIf Me.Debut_Facturation_M = "février" Then
Debut_Facturation_M = 2
ElseIf Me.Debut_Facturation_M = "mars" Then
Debut_Facturation_M = 3
ElseIf Me.Debut_Facturation_M = "avril" Then
Debut_Facturation_M = 4
ElseIf Me.Debut_Facturation_M = "mai" Then
Debut_Facturation_M = 5
ElseIf Me.Debut_Facturation_M = "juin" Then
Debut_Facturation_M = 6
ElseIf Me.Debut_Facturation_M = "juillet" Then
Debut_Facturation_M = 7
ElseIf Me.Debut_Facturation_M = "août" Then
Debut_Facturation_M = 8
ElseIf Me.Debut_Facturation_M = "septembre" Then
Debut_Facturation_M = 9
ElseIf Me.Debut_Facturation_M = "octobre" Then
Debut_Facturation_M = 10
ElseIf Me.Debut_Facturation_M = "novembre" Then
Debut_Facturation_M = 11
ElseIf Me.Debut_Facturation_M = "decembre" Then
Debut_Facturation_M = 12
End If
End With
With Me.Fin_Facturation_M
If Me.Fin_Facturation_M = "janvier" Then
Fin_Facturation_M = 1
ElseIf Me.Fin_Facturation_M = "février" Then
Fin_Facturation_M = 2
ElseIf Me.Fin_Facturation_M = "mars" Then
Fin_Facturation_M = 3
ElseIf Me.Fin_Facturation_M = "avril" Then
Fin_Facturation_M = 4
ElseIf Me.Fin_Facturation_M = "mai" Then
Fin_Facturation_M = 5
ElseIf Me.Fin_Facturation_M = "juin" Then
Fin_Facturation_M = 6
ElseIf Me.Fin_Facturation_M = "juillet" Then
Fin_Facturation_M = 7
ElseIf Me.Fin_Facturation_M = "août" Then
Fin_Facturation_M = 8
ElseIf Me.Fin_Facturation_M = "septembre" Then
Fin_Facturation_M = 9
ElseIf Me.Fin_Facturation_M = "octobre" Then
Fin_Facturation_M = 10
ElseIf Me.Fin_Facturation_M = "novembre" Then
Fin_Facturation_M = 11
ElseIf Me.Fin_Facturation_M = "decembre" Then
Fin_Facturation_M = 12
End If
End With
LL = 6
h = 25.5
Ln = 132
Lp = 126
Lc = 108
Lnb = 36
Lt = 66
Lm = 48
Lch = 90
Lw = 66
Ls = 60
Le = 49
Nbre_Free_Lance = 0
With Liste_Freelance_periode
.Debut_de_Facturation = Me.Debut_Facturation_J & "/" & Debut_Facturation_M & "/" & Me.Debut_Facturationt_A
.Fin_De_Facturation = Me.Fin_Facturation_J & "/" & Fin_Facturation_M & "/" & Me.Fin_de_Facturation_A
If Me.Debut_Facturation_M = Me.Fin_Facturation_M Then
Worksheets(cherche).Select



'--------------------Partie Freelance------------------
With Columns(2)
Set c = .Cells.Find("Nom", , xlValues, xlWhole, , , False)
If Not c Is Nothing Then
premier = c.Select
Selection.Offset(1, 0).Select
Do While Selection.Offset(0, 0) <> ""
Selection.Offset(1, 0).Select
Nbre_Free_Lance = Nbre_Free_Lance + 1
Loop
For NT = 1 To (Nbre_Free_Lance - 1)
With Liste_Freelance_periode
c.Select
Selection.Offset(1, 0).Select
'------Nom -----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")
With Obj
.Name = "Nom_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 0).Value
.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = LL
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Ln
.Height = h
End With


'------TextBox Prenom-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Prenom_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 1).Value
.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((2 * LL) + Ln)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Lp
.Height = h
End With
Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
'------TextBox Client-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Client_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 17).Value
.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((3 * LL) + Ln + Lp)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Lc
.Height = h
End With

Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
'------TextBox Nombre de jours-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Nbjrs_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 22).Value
.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((4 * LL) + Ln + Lp + Lc)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Lnb
.Height = h
End With
Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
'------TextBox TJM-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "TJM_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 6).Value
.Object.Value = Format(.Object.Value, "#,##0.0 €")
.FontSize = 10
.FontBold = True
.TextAlign = 2
.Left = ((5 * LL) + Ln + Lp + Lc + Lnb)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Lt
.Height = h
End With
Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
'------TextBox Marge-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Marge_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 7).Value
.Object.Value = Format(.Object.Value, "#,##0.0 €")
.FontSize = 10
.FontBold = True
.TextAlign = 2
.Left = ((6 * LL) + Ln + Lp + Lc + Lnb + Lt)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Lm
.Height = h
End With
Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
'------TextBox Chiffre-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Chiffre_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 23).Value
.Object.Value = Format(.Object.Value, "#,##0.0 €")
.FontSize = 10
.FontBold = True
.TextAlign = 2
.Left = ((7 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Lch
.Height = h
End With
Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
'------TextBox WOW-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Wow_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 24).Value
.Object.Value = Format(.Object.Value, "#,##0.0 €")
.FontSize = 10
.FontBold = True
.TextAlign = 2
.Left = ((8 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Lw
.Height = h
End With
Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
'------TextBox Sjtc-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Sjtc_" & (NT + 1)
.Object.Value = Selection.Offset(NT, 25).Value
.Object.Value = Format(.Object.Value, "#,##0.0 €")
.FontSize = 10
.FontBold = True
.TextAlign = 2
.Left = ((9 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch + Lw)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Ls
.Height = h
End With
Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
'------TextBox Eff-----
Set Obj = Liste_Freelance_periode.Controls.Add("forms.checkbox.1")

With Obj
.Name = "Eff_" & (NT + 1)
'.Object.Value = "Sjtc_" & (NT + 1)
.Left = ((10 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch + Lw + Ls)
.Top = ((168 + (NT * LL)) + (h * NT))
.Width = Le
.Height = h
End With
With Obj.VBProject.VBComponents _
("Eff_" & (NT + 1)).CodeModule
Code = "Sub checkbox_Click()" & vbCrLf

Code = Code & "If CheckBox.Value = True Then" & vbCrLf
Code = Code & "Me.Nom_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Prenom_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Client_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Chiffre_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Marge_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Me.TJM_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Me.WOW_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Me.Nbjrs_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Me.SJTC_(NT + 1).BackColor = &HFF&" & vbCrLf
Code = Code & "Else" & vbCrLf

Code = Code & "Me.Nom_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Prenom_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Client_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Chiffre_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.Marge_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & "Me.TJM_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & " Me.WOW_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & " Me.Nbjrs_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & " Me.SJTC_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
Code = Code & " End If" & vbCrLf
Code = Code & " End Sub" & vbCrLf


With Obj.VBProject. _
VBComponents("Eff_" & (NT + 1)).CodeModule
.AddFromString LeTexte
NextLine = .CountOfLines + 1

.InsertLines NextLine, Code
End With
End With
Set Cl = New Classe1
Set Cl.CheckBox = Obj
Collect.Add Cl

End With
Next NT
With Range(Cells(8, 2), Cells(60, 2))
Set d = .Cells.Find("Nom", , xlValues, xlWhole, , , False)
If Not d Is Nothing Then
premier = d.Select
Selection.Offset(1, 0).Select
Do While Selection.Offset(0, 0) <> ""
Selection.Offset(1, 0).Select
Nbre_Recru = Nbre_Recru + 1
Loop
For NR = 1 To (Nbre_Recru)
With Liste_Freelance_periode
d.Select
Selection.Offset(1, 0).Select
If NR <> "0" Then
'-----------LABEL RECRUTEMENT
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Recrutement"
.Object.Caption = "Recrutement"
.BackColor = &HFFFFC0
.FontSize = 16
.FontBold = True
.TextAlign = 2
.Left = 242
.Top = ((168 + ((NT + 1) * LL)) + (h * (NT + 1)))
.Width = 346
.Height = h
End With
'------Label Legende Recrutement -----
'-------Nom ------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Nom_" & (NR + 1)
.Object.Caption = "Nom"
.BackColor = &HFF8080
.FontSize = 14
.FontBold = True
.TextAlign = 2
.Left = LL
.Top = ((168 + (NT * LL)) + (h * NT) + (2 * h) + (2 * LL))
.Width = Ln
.Height = h
End With
'-------Prénom ------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Prenom"
.Object.Caption = "Prenom"
.BackColor = &HFF8080
.FontSize = 14
.FontBold = True
.TextAlign = 2
.Left = ((2 * LL) + Ln)
.Top = ((168 + (NT * LL)) + (h * NT) + (2 * h) + (2 * LL))
.Width = Lp
.Height = h
End With
'-------Date D'embauche------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Date_D'embauche"
.Object.Caption = "Début de Contrat"
.BackColor = &HFF8080
.FontSize = 14
.FontBold = True
.TextAlign = 2
.Left = ((3 * LL) + Ln + Lp)
.Top = ((168 + (NT * LL)) + (h * NT) + (2 * h) + (2 * LL))
.Width = Lc + 20
.Height = h
End With
'-------salaire------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Pretention"
.Object.Caption = "Salaire"
.BackColor = &HFF8080
.FontSize = 14
.FontBold = True
.TextAlign = 2
.Left = ((1 * LL) + Ln + Lp + Lc + Lnb)
.Top = ((168 + (NT * LL)) + (h * NT) + (2 * h) + (2 * LL))
.Width = Lt + 46
.Height = h
End With
'-------Honoraires------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Honoraires"
.Object.Caption = "WoW"
.BackColor = &HFF8080
.FontSize = 14
.FontBold = True
.TextAlign = 2
.Left = ((6 * LL) + Ln + Lp + Lc + Lnb + Lt + 20)
.Top = ((168 + (NT * LL)) + (h * NT) + (2 * h) + (2 * LL))
.Width = Lm
.Height = h
End With
'-------Part SJTC------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Part_SJTC"
.Object.Caption = "SJTC"
.BackColor = &HFF8080
.FontSize = 14
.FontBold = True
.TextAlign = 2
.Left = ((6 * LL) + Ln + Lp + Lc + Lnb + Lm + Lch)
.Top = ((168 + (NT * LL)) + (h * NT) + (2 * h) + (2 * LL))
.Width = Lm
.Height = h
End With
'-------Montant WOW------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Montant_WOW"
.Object.Caption = "Montant WoW"
.BackColor = &HFF8080
.FontSize = 14
.FontBold = True
.TextAlign = 2
.Left = ((4 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch)
.Top = ((168 + (NT * LL)) + (h * NT) + (2 * h) + (2 * LL))
.Width = Lch + 20
.Height = h
End With
'-------Montant SJTC------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.Label.1")
With Obj
.Name = "Montant_SJTC"
.Object.Caption = "Montant SJTC"
.BackColor = &HFF8080
.FontSize = 14
.FontBold = True
.TextAlign = 2
.Left = ((8 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch + Lch)
.Top = ((168 + (NT * LL)) + (h * NT) + (2 * h) + (2 * LL))
.Width = Lch + 20
.Height = h
End With
'-------Recrutement Textbox ------------
'-------Nom------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Nom_" & NR
.Object.Value = Selection.Offset(NR - 1, 0).Value

.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = LL
.Top = ((168 + (NR * LL)) + (h * NR) + ((2 * h) + (3 * LL) + (NT * LL) + (h * NT)))
.Width = Ln
.Height = h
End With
'-------Prenom------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Prenom_" & NR
.Object.Value = Selection.Offset(NR - 1, 1).Value

.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((2 * LL) + Ln)
.Top = ((168 + (NR * LL)) + (h * NR) + ((2 * h) + (3 * LL)) + (NT * LL) + (h * NT))
.Width = Lp
.Height = h
End With
'-------Date D'embauche------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Date_D'embauche_" & NR
.Object.Value = Selection.Offset(NR - 1, 14).Value

.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((3 * LL) + Ln + Lp)
.Top = ((168 + (NR * LL)) + (h * NR) + ((2 * h) + (3 * LL)) + (NT * LL) + (h * NT))
.Width = Lc + 20
.Height = h
End With
'-------Salaire------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Salaire_" & NR
.Object.Value = Selection.Offset(NR - 1, 10).Value
.Object.Value = Format(.Object.Value, "#,##0.0 €")
.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((1 * LL) + Ln + Lp + Lc + Lnb)
.Top = ((168 + (NR * LL)) + (h * NR) + ((2 * h) + (3 * LL)) + (NT * LL) + (h * NT))
.Width = Lt + 46
.Height = h
End With
'-------Honoraires------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Honoraires_" & NR
.Object.Value = Selection.Offset(NR - 1, 11).Value & "%"

.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((6 * LL) + Ln + Lp + Lc + Lnb + Lt + 20)
.Top = ((168 + (NR * LL)) + (h * NR) + ((2 * h) + (3 * LL)) + (NT * LL) + (h * NT))
.Width = Lm
.Height = h
End With
'-------Part SJTC------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "SJTC_" & NR
.Object.Value = 100 - Selection.Offset(NR - 1, 12).Value & "%"

.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((6 * LL) + Ln + Lp + Lc + Lnb + Lm + Lch)
.Top = ((168 + (NR * LL)) + (h * NR) + ((2 * h) + (3 * LL)) + (NT * LL) + (h * NT))
.Width = Lm
.Height = h
End With
'-------Montant WOW------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Montant_WoW_" & NR
.Object.Value = Selection.Offset(NR - 1, 16).Value
.Object.Value = Format(.Object.Value, "#,##0.0 €")
.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((4 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch)
.Top = ((168 + (NR * LL)) + (h * NR) + ((2 * h) + (3 * LL)) + (NT * LL) + (h * NT))
.Width = Lch + 20
.Height = h
End With
'-------Montant SJTC------------
Set Obj = Liste_Freelance_periode.Controls.Add("forms.TextBox.1")

With Obj
.Name = "Montant_Sjtc_" & NR
.Object.Value = Selection.Offset(NR - 1, 17).Value
.Object.Value = Format(.Object.Value, "#,##0.0 €")
.FontSize = 12
.FontBold = True
.TextAlign = 2
.Left = ((8 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch + Lch)
.Top = ((168 + (NR * LL)) + (h * NR) + ((2 * h) + (3 * LL)) + (NT * LL) + (h * NT))
.Width = Lch + 20
.Height = h
End With
Set Cl = New Classe1
Set Cl.TextBox = Obj
Collect.Add Cl
End If
End With
Next NR
End If
End With
With Liste_Freelance_periode
c.Select
Selection.Offset(1, 0).Select
.Valider_les_freelances.Top = 168 + h + (Nbre_Free_Lance * (h + LL) + (Nbre_Recru * (h + LL) + ((2 * h) + LL)) + (h + (3 * LL)))
.retour.Top = 168 + h + (Nbre_Free_Lance * (h + LL) + (Nbre_Recru * (h + LL) + ((2 * h) + LL)) + (h + (3 * LL)))
.Height = 168 + h + (Nbre_Free_Lance * (h + LL)) + 80 + (Nbre_Recru * (h + LL) + ((2 * h) + LL) + (h + (3 * LL)))
.Nom_1 = Selection.Offset.Value
.Prenom_1 = Selection.Offset(0, 1).Value
.Client_1 = Selection.Offset(0, 17).Value
.Nbjrs_1 = Selection.Offset(0, 22).Value
.TJM_1 = Selection.Offset(0, 6).Value
.TJM_1.Value = Format(.TJM_1.Value, "#,##0.0 €")
.Marge_1 = Selection.Offset(0, 7).Value
.Marge_1.Value = Format(.Marge_1.Value, "#,##0.0 €")
.Chiffre_1 = Selection.Offset(0, 23).Value
.Chiffre_1.Value = Format(.Chiffre_1.Value, "#,##0.0 €")
.WOW_1 = Selection.Offset(0, 24).Value
.WOW_1.Value = Format(.WOW_1.Value, "#,##0.0 €")
.SJTC_1 = Selection.Offset(0, 25).Value
.SJTC_1.Value = Format(.SJTC_1.Value, "#,##0.0 €")




End With

Selection.Offset(1, 0).Select

End If
End With
Else
MsgBox ("attention il y a plusieurs mois de facturation")
End If
End With
Liste_Freelance_periode.Show

Unload Me
End Sub

et en message d'erreur les photos ci joint


merci pour votre aide
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474 > titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023
13 janv. 2022 à 14:44
Tu n'as pas précisé le langage (basic) dans les balises.
1
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1 > yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024
13 janv. 2022 à 14:51
ah désolé
dois je modifié quelque chose ?
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474
13 janv. 2022 à 15:26
Il est préférable que tu partages un fichier xlsm qui permet de reproduire le soucis.
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1
13 janv. 2022 à 15:41
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1
13 janv. 2022 à 16:06
Re,
Petite précision sur la macro résistante
macro creer la facture
choisir le mois de février ( la ou j'ai rempli des données bidons)
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474 > titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023
13 janv. 2022 à 17:01
Se pourrait-il que ton code VBA soit absent de ton fichier xlsm?
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1 > yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024
13 janv. 2022 à 17:16
Tout est dans le fichier personal.xlsb
https://www.cjoint.com/c/LAnoetpcosk
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474 > titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023
13 janv. 2022 à 17:21
Peux-tu partager un fichier xlsm avec le code VBA inclus?
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474
13 janv. 2022 à 18:59
Je pense que le code n'est pas associé au checkbox, mais plutôt à la forme.
Et donc:
With ThisWorkbook.VBProject.VBComponents("Liste_Freelance_periode").CodeModule

au lieu de
With Obj.VBProject.VBComponents _
                ("Eff_" & (NT + 1)).CodeModule


Je pense alors important de mettre le nom du checkbox dans le code:
Code = "Sub Eff_" & (NT + 1) & "_Click()" & vbCrLf
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1
Modifié le 14 janv. 2022 à 09:18
Bonjour yg_be,
Alors j'ai essayé ton code mais en vain..:(
de plus je souhaite ecrire le code dans les checkbox donc je vois mal ecrire un code dans le workbook.
bon j'ai essayé ce code pour déclarer vouloir ecrire dans le checkBOx: résultat , il me déclare impossible de trouver l'objet.. j'avance a petit pas
voici mon code
Set Obj = Liste_Freelance_periode.Controls.Add("forms.checkbox.1")
           
            With Obj
            .Name = "Eff_" & (NT + 1)
            '.Object.Value = "Sjtc_" & (NT + 1)
            .Left = ((10 * LL) + Ln + Lp + Lc + Lnb + Lt + Lm + Lch + Lw + Ls)
            .Top = ((168 + (NT * LL)) + (h * NT))
            .Width = Le
            .Height = h
            NTCheckB = "Eff_" & (NT + 1)
            MsgBox (NTCheckB)
                           
    End With
    With Me.Controls(NTCheckB).VBProject.VBComponents("forms.checkbox.1").CodeModule
                Code = "Sub & NTCheckB & _Click()" & vbCrLf
                
                Code = Code & "If CheckBox.Value = True Then" & vbCrLf
                Code = Code & "Me.Nom_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Prenom_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Client_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Chiffre_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Marge_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.TJM_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.WOW_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Nbjrs_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.SJTC_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Else" & vbCrLf
                
                Code = Code & "Me.Nom_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Prenom_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Client_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Chiffre_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Marge_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.TJM_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
               Code = Code & " Me.WOW_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
               Code = Code & " Me.Nbjrs_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
               Code = Code & " Me.SJTC_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
               Code = Code & " End If" & vbCrLf
               Code = Code & " End Sub" & vbCrLf

   
            With Me.Controls(NTCheckB).VBProject.VBComponents("forms.checkbox.1").CodeModule
.AddFromString LeTexte
       NextLine = .CountOfLines + 1
    
      .InsertLines NextLine, Code
    End With
    End With
               Set Cl = New Classe1
    Set Cl.CheckBox = Obj
    Collect.Add Cl
    
           End With
           
           Next NT

je me suis servi du code d'écriture de macro dans un "onglet non crée" pour le modifier et l'adapter à un checkbox.. peut être est ce une autre procédure
merci pour le temps passé :)
belle journée
Titi
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474 > titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023
14 janv. 2022 à 10:05
1) Tu ne montres pas ton essai de mon code, ni ne décris l'erreeur rencontrée

2) je t'écris que le code qui réagit au checkbox doit être associé à la forme, pas au checkbox, et tu réponds que tu te vois mal ecrire un code dans le workbook.
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1 > yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024
Modifié le 14 janv. 2022 à 10:15
1)Avec ton essai cela ne fais rien..l'useform se lance bien avec le nombre de textbox voulu mais la partie de checkbox ou je souhaite que quand il est coché les autres textbox de la meme ligne soit en interieur rouge ne fonctionne pas.
voici le code ecrit
' With Me.Controls(NTCheckB).VBProject.VBComponents("forms.checkbox.1").CodeModule
   With ThisWorkbook.VBProject.VBComponents("Liste_Freelance_periode").CodeModule
                Code = "Sub & NTCheckB & _Click()" & vbCrLf
                
                Code = Code & "If CheckBox.Value = True Then" & vbCrLf
                Code = Code & "Me.Nom_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Prenom_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Client_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Chiffre_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Marge_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.TJM_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.WOW_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Nbjrs_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.SJTC_(NT + 1).BackColor = &HFF&" & vbCrLf
                Code = Code & "Else" & vbCrLf
                
                Code = Code & "Me.Nom_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Prenom_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Client_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Chiffre_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Marge_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.TJM_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
               Code = Code & " Me.WOW_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
               Code = Code & " Me.Nbjrs_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
               Code = Code & " Me.SJTC_(NT + 1).BackColor = &HFFFFFF" & vbCrLf
               Code = Code & " End If" & vbCrLf
               Code = Code & " End Sub" & vbCrLf

                With ThisWorkbook.VBProject.VBComponents("Liste_Freelance_periode").CodeModule
            'With Me.Controls(NTCheckB).VBProject.VBComponents("forms.checkbox.1").CodeModule
.AddFromString LeTexte
       NextLine = .CountOfLines + 1
    
      .InsertLines NextLine, Code
    End With
    End With

2) le Thisworkbook est bien en traduction "sur l'objet en court de travail"?
donc l'interaction n'est pas sur l'objet liste_freelance mais les checkbox ;)
enfin j'espere me faire comprendre car je suis autodidacte ;))))
merci
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474 > titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023
14 janv. 2022 à 11:03
1) As-tu éliminé le code d'erreur, ton code s'exécute-t-il? Alors tu progresses. Examine, maintenant, après l'exécution de ton code, le code du formulaire Liste_Freelance_periode. As-tu lu ma seconde suggestion en #17? Le nom du checkbox est-il NTCheckB?

2) Que veux-tu dire par autodidacte? Que tu copies du code sans le comprendre et que tu ne prends pas le temps de te former ni de lire la documentation? Une simple recherche te permettrait de comprendre qu'un "workbook", c'est un fichier Excel, et que "ThisWorkbook" est une référence au fichier contenant le code qui s'exécute.
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1
14 janv. 2022 à 14:43
Cher yg_be,
1) j'ai éliminé mon erreur en suivant le thisworbook : ( dans mon resonnement cerebral, je pensais que l'écriture de private se faisait sur le textbox et non sur le thisworkbook ... j'apprends de jour en jour )
j'ai bien l'écriture mais cela ne réagit pas quand je coche le checkbox ---> donc il ne doit pas reconnaitre le nom du checkbox avec la sub ..
2) autodidacte: je n'ai pas de formation d'informaticien ou dev ... des fois les choses peuvent paraitre logique mais pour moi il y a deux ans c'était du chinois... ;)
mon domaine est plus dessinateur 3D donc j'ai des logique que peut etre tu n'as pas :)))
je poursuis mes recherches
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474
14 janv. 2022 à 15:03
As-tu examiné après l'exécution de ton code, le code du formulaire Liste_Freelance_periode?

As-tu lu ma seconde suggestion en #17?

Le nom du checkbox est-il NTCheckB?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474
14 janv. 2022 à 15:14
En voyant ton fichier, je me demande comment et pourquoi tu en es arrivé à quelque-chose d'aussi complexe.

J'ai comme l'impression que tu n'as pas choisi le bon logiciel (Excel) et/ou que tu as fait de mauvais choix au moment de la conception de ce projet.

Si tu fais cela pour apprendre en bricolant, parfait. Je pense, cependant, que cela t'amène à utiliser des techniques complexes rarement utilisées (donc peu utiles), et que le résultat sera un chateau de carte difficile à faire évoluer.
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1
15 janv. 2022 à 08:52
Bonjour yg_be,
J'ai bien examiné le formulaire liste_freelance_periode
le code est bien présent, j'ai bien mis ta suggestion en #17 avec la nomination de la sub et tout le reste
sur le formulaire tout est ok..
Le Nom de la sub est bien Eff_+( la boucle en cours )
-j'ai modifié chaque Me. avec "& (NT+1)&" pour que le chiffre soit bon
mon code dans le formulaire donne cela
With ThisWorkbook.VBProject.VBComponents("Liste_Freelance_periode").CodeModule
                Code = "Private Sub Eff_" & (NT + 1) & "_Click()" & vbCrLf
                
                Code = Code & "If Eff_" & (NT + 1) & ".Value = True Then" & vbCrLf
                Code = Code & "Me.Nom_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Prenom_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Client_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Chiffre_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Marge_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.TJM_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.WOW_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.Nbjrs_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Me.SJTC_" & (NT + 1) & ".BackColor = &HFF&" & vbCrLf
                Code = Code & "Else" & vbCrLf
                
                Code = Code & "Me.Nom_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Prenom_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Client_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Chiffre_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Marge_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.TJM_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.WOW_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.Nbjrs_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "Me.SJTC_" & (NT + 1) & ".BackColor = &HFFFFFF" & vbCrLf
                Code = Code & "End If" & vbCrLf
                Code = Code & "End Sub" & vbCrLf

                With ThisWorkbook.VBProject.VBComponents("Liste_Freelance_periode").CodeModule
            '.Controls(NTCheckB).VBProject. _
VBComponents("forms.checkbox.1").CodeModule
.AddFromString LeTexte
       NextLine = .CountOfLines + 1
    
      .InsertLines NextLine, Code
    End With
   End With

Il va falloir que je supprime les macros quand mon formulaire se fermera sinon a chaque fois que j'ouvre l'uf il va creer la sub..
maintenant quand mon userform est activé ben j'ai beau coché ...rien ne se passe
Je continue mes recherches sur le pourquoi cela ne réagit pas et/ou pour le checkbox 2 par exemple ne fait pas réagir la sub click Eff_2 ..
Belle journee
merci pour ton aide
Titi
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474
15 janv. 2022 à 11:34
Tu progresses.
Utilises-tu l'explorateur de projet dans l'éditeur VBA?
Chaque "page" de code VBA se trouve dans un des éléments suivants: une feuille, un formulaire, un module ou un module de classe.
Le code que tu as montré jusqu'à présent (Valider_Les_Dates_Click()) se trouve dans le formulaire nommé "Periode_Facture".
La fonction Valider_Les_Dates_Click() fait deux types d'actions:
- elle modifie la présentation du formulaire "Liste_Freelance_periode"
- elle modifie le code du formulaire "Liste_Freelance_periode"

Je pense que l'extrait de code que tu as partagé en #25 vient du formulaire "Periode_Facture", pas du formulaire "Liste_Freelance_periode".

Par ailleurs, je ne comprends pas comment la ligne 28 de ton extrait peut fonctionner.
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1 > yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024
16 janv. 2022 à 18:35
Bonsoir yg_be,
Alors non je n'utilise pas l'explorateur d'objets.
oui le code en #25 est bien une écriture dans le formulaire période facture:
c 'est le code avec la boucle me créant les textbox dynamiques en fonction du nombre inscrits et selon le mois demandé.
Dans ma réflexion je crée le code "sub Eff_+ _click" dans le formulaire liste_des freelances_periode comme tu me l'a signalé ;)
Et dans ma boucle de création des checkbox je souhaites écrire le code ...
bon le code est bien ecrit, tout roule mais quand j'ai l'uf devant moi avec les checkbox, je clique et cela ne change pas les couleurs des textboxs demandés.
Donc j'en déduis que les checbox ne sont pas en liens avec le code ?
et je ne peux vérifier le nom des checkbox vu qu'ils sont en dynamiques ou du moins je ne sais pas comment vérifier
voila mon avancement....;(
je continue mes recherches
dis moi si je suis dans
Bonne soirée
Titi
0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474 > titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023
16 janv. 2022 à 20:07
Peux-tu partager le code qui se trouve, après l'exécution de Valider_Les_Dates_Click(), dans le formulaire "liste_des freelances_periode"?
0
titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023 1 > yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024
16 janv. 2022 à 20:35
alors voici le code dans le formulaire liste_des_freelance_ periode avant le valider
Public Sub Eff_1_Click()
If Eff_1.Value = True Then

Me.Nom_1.BackColor = &HFF&
Me.Prenom_1.BackColor = &HFF&
Me.Client_1.BackColor = &HFF&
Me.Chiffre_1.BackColor = &HFF&
Me.Marge_1.BackColor = &HFF&
Me.TJM_1.BackColor = &HFF&
Me.WOW_1.BackColor = &HFF&
Me.Nbjrs_1.BackColor = &HFF&
Me.SJTC_1.BackColor = &HFF&
Else

Me.Nom_1.BackColor = &HFFFFFF
Me.Prenom_1.BackColor = &HFFFFFF
Me.Client_1.BackColor = &HFFFFFF
Me.Chiffre_1.BackColor = &HFFFFFF
Me.Marge_1.BackColor = &HFFFFFF
Me.TJM_1.BackColor = &HFFFFFF
Me.WOW_1.BackColor = &HFFFFFF
Me.Nbjrs_1.BackColor = &HFFFFFF
Me.SJTC_1.BackColor = &HFFFFFF
End If
End Sub



Private Sub Label31_Click()

End Sub

Private Sub retour_Click()
Unload Me
End Sub

Sub Valider_les_freelances_Click()
Dim Ddc As Variant
Dim ok As Boolean
Dim T As Control
Dim NFac As Variant
Dim NbreFree As Integer
Dim NomTextbox As String
NomTextbox = "Nom_1"
Dim c As Variant
'Ddc = Worksheets("Contrat " & Me.Nom_1).Cells(9, 2).Value

With Liste_Freelance_periode.Controls
    For Each T In Liste_Freelance_periode.Controls
        If TypeOf T.Object Is MSForms.TextBox Then _
           ok = (T.Name = NomTextbox)
           MsgBox (ok)
    Next T
    MsgBox (ok)
End With

Call Creer_Facture
NFac = ActiveSheet.Name
With NFac
Cells(15, 3).Value = Me.Nom_1
Cells(15, 2).Value = Ddc
Cells(15, 5).Value = Me.Prenom_1
Cells(15, 7).Value = Me.Debut_de_Facturation
Cells(15, 8).Value = Me.Fin_De_Facturation
Cells(15, 11).Value = Me.SJTC_1
End With
Sheets("Factures Réalisées").Activate
With Range(Cells(4, 2), Cells(60, 2))
Set c = .Cells.Find(NFac, , xlValues, xlWhole, , , False)
            If Not c Is Nothing Then
            premier = c.Select
           Selection.Offset(0, 5).Value = Me.SJTC_1
           
           Selection.Offset(0, 2).Value = Mid(NFac, 13)
           
         End If
           End With
           
Unload Me
End Sub

et voici apres le click valider
Public Sub Eff_1_Click()
If Eff_1.Value = True Then

Me.Nom_1.BackColor = &HFF&
Me.Prenom_1.BackColor = &HFF&
Me.Client_1.BackColor = &HFF&
Me.Chiffre_1.BackColor = &HFF&
Me.Marge_1.BackColor = &HFF&
Me.TJM_1.BackColor = &HFF&
Me.WOW_1.BackColor = &HFF&
Me.Nbjrs_1.BackColor = &HFF&
Me.SJTC_1.BackColor = &HFF&
Else

Me.Nom_1.BackColor = &HFFFFFF
Me.Prenom_1.BackColor = &HFFFFFF
Me.Client_1.BackColor = &HFFFFFF
Me.Chiffre_1.BackColor = &HFFFFFF
Me.Marge_1.BackColor = &HFFFFFF
Me.TJM_1.BackColor = &HFFFFFF
Me.WOW_1.BackColor = &HFFFFFF
Me.Nbjrs_1.BackColor = &HFFFFFF
Me.SJTC_1.BackColor = &HFFFFFF
End If
End Sub



Private Sub Label31_Click()

End Sub

Private Sub retour_Click()
Unload Me
End Sub

Sub Valider_les_freelances_Click()
Dim Ddc As Variant
Dim ok As Boolean
Dim T As Control
Dim NFac As Variant
Dim NbreFree As Integer
Dim NomTextbox As String
NomTextbox = "Nom_1"
Dim c As Variant
'Ddc = Worksheets("Contrat " & Me.Nom_1).Cells(9, 2).Value

With Liste_Freelance_periode.Controls
    For Each T In Liste_Freelance_periode.Controls
        If TypeOf T.Object Is MSForms.TextBox Then _
           ok = (T.Name = NomTextbox)
           MsgBox (ok)
    Next T
    MsgBox (ok)
End With

Call Creer_Facture
NFac = ActiveSheet.Name
With NFac
Cells(15, 3).Value = Me.Nom_1
Cells(15, 2).Value = Ddc
Cells(15, 5).Value = Me.Prenom_1
Cells(15, 7).Value = Me.Debut_de_Facturation
Cells(15, 8).Value = Me.Fin_De_Facturation
Cells(15, 11).Value = Me.SJTC_1
End With
Sheets("Factures Réalisées").Activate
With Range(Cells(4, 2), Cells(60, 2))
Set c = .Cells.Find(NFac, , xlValues, xlWhole, , , False)
            If Not c Is Nothing Then
            premier = c.Select
           Selection.Offset(0, 5).Value = Me.SJTC_1
           
           Selection.Offset(0, 2).Value = Mid(NFac, 13)
           
         End If
           End With
           
Unload Me
End Sub
Private Sub Eff_2_Click()
If Eff_2.Value = True Then
Me.Nom_2.BackColor = &HFF&
Me.Prenom_2.BackColor = &HFF&
Me.Client_2.BackColor = &HFF&
Me.Chiffre_2.BackColor = &HFF&
Me.Marge_2.BackColor = &HFF&
Me.TJM_2.BackColor = &HFF&
Me.WOW_2.BackColor = &HFF&
Me.Nbjrs_2.BackColor = &HFF&
Me.SJTC_2.BackColor = &HFF&
Else
Me.Nom_2.BackColor = &HFFFFFF
Me.Prenom_2.BackColor = &HFFFFFF
Me.Client_2.BackColor = &HFFFFFF
Me.Chiffre_2.BackColor = &HFFFFFF
Me.Marge_2.BackColor = &HFFFFFF
Me.TJM_2.BackColor = &HFFFFFF
Me.WOW_2.BackColor = &HFFFFFF
Me.Nbjrs_2.BackColor = &HFFFFFF
Me.SJTC_2.BackColor = &HFFFFFF
End If
End Sub

Private Sub Eff_3_Click()
If Eff_3.Value = True Then
Me.Nom_3.BackColor = &HFF&
Me.Prenom_3.BackColor = &HFF&
Me.Client_3.BackColor = &HFF&
Me.Chiffre_3.BackColor = &HFF&
Me.Marge_3.BackColor = &HFF&
Me.TJM_3.BackColor = &HFF&
Me.WOW_3.BackColor = &HFF&
Me.Nbjrs_3.BackColor = &HFF&
Me.SJTC_3.BackColor = &HFF&
Else
Me.Nom_3.BackColor = &HFFFFFF
Me.Prenom_3.BackColor = &HFFFFFF
Me.Client_3.BackColor = &HFFFFFF
Me.Chiffre_3.BackColor = &HFFFFFF
Me.Marge_3.BackColor = &HFFFFFF
Me.TJM_3.BackColor = &HFFFFFF
Me.WOW_3.BackColor = &HFFFFFF
Me.Nbjrs_3.BackColor = &HFFFFFF
Me.SJTC_3.BackColor = &HFFFFFF
End If
End Sub

0
yg_be Messages postés 22859 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 7 juin 2024 1 474 > titi17-08 Messages postés 122 Date d'inscription mercredi 29 janvier 2020 Statut Membre Dernière intervention 20 janvier 2023
17 janv. 2022 à 15:13
Je constate, comme toi, que seul le premier checkbox réagit.
En fait, bien que les lignes supplémentaires soient visibles, elles ne sont par effectives, comme si elles avaient été créés dans une copie temporaire du formulaire. Ce qui se confirme à la fermeture du formulaire, où toutes les modifications ont disparu.
Contrairement au code du formulaire, où le code ajouté est bien permanent.
1