Compter des checkbox dans une macro Word

rico350 Messages postés 7 Date d'inscription vendredi 19 novembre 2004 Statut Membre Dernière intervention 18 avril 2005 - 18 avril 2005 à 11:42
rico350 Messages postés 7 Date d'inscription vendredi 19 novembre 2004 Statut Membre Dernière intervention 18 avril 2005 - 18 avril 2005 à 16:38
Bonjour à tous,

Je suis novice en la matière et j'ai besoin de la chose suivante :

J'ai un document Word dans laquelle j'ai insérer des checkbox.

Je souhaiterais afficher 2 compteurs :
-> un compteur qui calcul le nombre total de checkbox dans mon document word
-> un compteur qui calcul le nombre total de checkbox coché d'un groupe donné

Pour finir, je souhaite calculer et afficher la ratio de ces compteurs.

Merci pour votre aide !

1 réponse

rico350 Messages postés 7 Date d'inscription vendredi 19 novembre 2004 Statut Membre Dernière intervention 18 avril 2005
18 avril 2005 à 16:38
J'ai trouve le code suivant mais il ne fonctionne pas chez moi...
intFFCount est tjs égal à 0... Une idée ?



Sub TextFFArray()

Dim mFormField As FormField
Dim i As Integer
Dim intFFCount As Integer
Dim intTextFFCount As Integer
Dim TextFormFields() As String
Dim sMessage As String
Dim var

For Each mFormField In ActiveDocument.FormFields()
' increase total count of fields
intFFCount = intFFCount + 1
If mFormField.Type = wdFieldFormTextInput Then
' increase total count of text fields
intTextFFCount = intTextFFCount + 1
ReDim Preserve TextFormFields(i)
TextFormFields(i) = mFormField.Name
i = i + 1
End If
Next
ReDim Preserve TextFormFields(i)
' may as well use this again
i = 0
' loop through array getting field name &
' using it to get resulting value
For var = 1 To intTextFFCount
sMessage = sMessage & _
"Field name:= " & TextFormFields(i) & " " & _
"Value:= " & ActiveDocument.FormFields(TextFormFields(i)).Result & _
vbCrLf
i = i + 1
Next
' display message with:
' total number of fields,
' total number of textboxes
' each textbox name and result
MsgBox "There are " & intFFCount & " FormFields in this " & _
"document, including " & intTextFFCount & " textboxes." & _
vbCrLf & " The contents of those textboxes are:" & vbCrLf & _
sMessage
End Sub
0
Rejoignez-nous