Checkbox word
Ttenkarton
Messages postés
14
Statut
Membre
-
Ttenkarton Messages postés 14 Statut Membre -
Ttenkarton Messages postés 14 Statut Membre -
Bonjour,
j essai de programmer une macro qui sera lancé a partir d'une checkbox, voila mon code :
Private Sub CheckBox20_Click()
If CheckBox20.Value = True Then
With Selection.Cells(1).Shading
.BackgroundPatternColorIndex = wdRed
CheckBox20.BackColor = &HFF&
ActiveDocument.Tables(12).Cell(1, 1).Shading.ForegroundPatternColorIndex = wdRed
End With
Else
With Selection.Cells(1).Shading
.BackgroundPatternColor = &H80FFFF
CheckBox20.BackColor = &H80FFFF
ActiveDocument.Tables(12).Cell(1, 1).Shading.BackgroundPatternColor = &HE0E0E0
End With
End If
End Sub
jusque la ca marche bien, mais comme j ai environ 200 Checkbox a controler de la meme facon j aimerais allerger mon code sans le repeter 200 fois, mais dans une seule macro.
j aimerais donc stocker ma checkbox dans une variable et travailler sur cette variable
avec un code du genre :
Dim NomCheckbox As Integer
Dim NomTableau As Integer
Dim chkbox As CheckBox
Public Sub CheckBox13_Click()
NomCheckbox = 13
NomTableau = 11
MsgBox NomCheckbox
MsgBox NomTableau
Call RisqueCasse
End Sub
Public Sub RisqueCasse()
If ActiveDocument.FormFields(NomCheckbox).CheckBox.Value = True Then
With Selection.Cells(1).Shading
.BackgroundPatternColorIndex = wdRed
MsgBox "je passe par la"
ActiveDocument.FormFields(NomCheckbox).CheckBox = &HFF&
ActiveDocument.Tables(NomTableau).Cell(1, 1).Shading.ForegroundPatternColorIndex = wdRed
End With
Else
With Selection.Cells(1).Shading
.BackgroundPatternColor = &H80FFFF
ActiveDocument.FormFields(NomCheckbox).CheckBox.Value = &H80FFFF
ActiveDocument.Tables(NomTableau).Cell(1, 1).Shading.BackgroundPatternColor = &HE0E0E0
End With
End If
End Sub
mais voila ca marche pas, donc comme je suis novice dans la programmation de macro si quelqu un pouvait m aider ca serait bien sympa
j essai de programmer une macro qui sera lancé a partir d'une checkbox, voila mon code :
Private Sub CheckBox20_Click()
If CheckBox20.Value = True Then
With Selection.Cells(1).Shading
.BackgroundPatternColorIndex = wdRed
CheckBox20.BackColor = &HFF&
ActiveDocument.Tables(12).Cell(1, 1).Shading.ForegroundPatternColorIndex = wdRed
End With
Else
With Selection.Cells(1).Shading
.BackgroundPatternColor = &H80FFFF
CheckBox20.BackColor = &H80FFFF
ActiveDocument.Tables(12).Cell(1, 1).Shading.BackgroundPatternColor = &HE0E0E0
End With
End If
End Sub
jusque la ca marche bien, mais comme j ai environ 200 Checkbox a controler de la meme facon j aimerais allerger mon code sans le repeter 200 fois, mais dans une seule macro.
j aimerais donc stocker ma checkbox dans une variable et travailler sur cette variable
avec un code du genre :
Dim NomCheckbox As Integer
Dim NomTableau As Integer
Dim chkbox As CheckBox
Public Sub CheckBox13_Click()
NomCheckbox = 13
NomTableau = 11
MsgBox NomCheckbox
MsgBox NomTableau
Call RisqueCasse
End Sub
Public Sub RisqueCasse()
If ActiveDocument.FormFields(NomCheckbox).CheckBox.Value = True Then
With Selection.Cells(1).Shading
.BackgroundPatternColorIndex = wdRed
MsgBox "je passe par la"
ActiveDocument.FormFields(NomCheckbox).CheckBox = &HFF&
ActiveDocument.Tables(NomTableau).Cell(1, 1).Shading.ForegroundPatternColorIndex = wdRed
End With
Else
With Selection.Cells(1).Shading
.BackgroundPatternColor = &H80FFFF
ActiveDocument.FormFields(NomCheckbox).CheckBox.Value = &H80FFFF
ActiveDocument.Tables(NomTableau).Cell(1, 1).Shading.BackgroundPatternColor = &HE0E0E0
End With
End If
End Sub
mais voila ca marche pas, donc comme je suis novice dans la programmation de macro si quelqu un pouvait m aider ca serait bien sympa
A voir également:
- Checkbox word
- Word 2013 - Télécharger - Traitement de texte
- Tableau word - Guide
- Word et excel gratuit - Guide
- Espace insécable word - Guide
- Supprimer page word - Guide