Bonjour le fofo,

J'utilise un formulaire composé de checkbox pour afficher le total des chechbox cochées.
Je souhaite injecter ce total dans un document word à l'aide d'un signet.
Mon problème est que l'injection se réalise à chaque cochage c'est à dire que cela renvoie une suite de chiffre correspondant aux totaux intermédiaires et non au total final.
Quelqu'un aurait-il une idée ?
Merci d'avance

Voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Option Explicit
 
 
Public Sub MMS()
 
Dim appWrd As Word.Application
Dim docWord As Word.Document
Dim MonControl As Control
Dim OT As Variant, OS As Variant, APP As Variant, CALC As Variant, RAPP As Variant, LANG As Variant, PRAX As Variant
Dim i As Integer
Dim Total_OT As Integer, Total_OS As Integer, Total_APP As Integer, Total_CALC As Integer, Total_RAPP As Integer, Total_LANG As Integer, Total_PRAX As Integer
 
 
OT = Array("CheckBox_OT1", "CheckBox_OT2", "CheckBox_OT3", "CheckBox_OT4", "CheckBox_OT5")
 
OS = Array("CheckBox_OS1", "CheckBox_OS2", "CheckBox_OS3", "CheckBox_OS4", "CheckBox_OS5")
 
APP = Array("CheckBox_APP1", "CheckBox_APP2", "CheckBox_APP3")
 
CALC = Array("CheckBox_CALC1", "CheckBox_CALC2", "CheckBox_CALC3", "CheckBox_CALC4", "CheckBox_CALC5")
 
RAPP = Array("CheckBox_RAPP1", "CheckBox_RAPP2", "CheckBox_RAPP3")
 
LANG = Array("CheckBox_LANG1", "CheckBox_LANG2", "CheckBox_LANG3", "CheckBox_LANG4", "CheckBox_LANG5", "CheckBox_LANG6", "CheckBox_LANG7", "CheckBox_LANG8")
 
PRAX = Array("CheckBox_PRAX")
 
 
With USF_comp
 
    .Total_MMSE = "0"
 
    For Each MonControl In .Controls
 
        For i = LBound(OT, 1) To UBound(OT, 1)
            If MonControl.Name = OT(i) Then
               If MonControl = True Then Total_OT = Total_OT + 1
            End If
        Next i
 
        For i = LBound(OS, 1) To UBound(OS, 1)
            If MonControl.Name = OS(i) Then
               If MonControl = True Then Total_OS = Total_OS + 1
            End If
        Next i
 
        For i = LBound(APP, 1) To UBound(APP, 1)
            If MonControl.Name = APP(i) Then
               If MonControl = True Then Total_APP = Total_APP + 1
            End If
        Next i
 
        For i = LBound(CALC, 1) To UBound(CALC, 1)
            If MonControl.Name = CALC(i) Then
               If MonControl = True Then Total_CALC = Total_CALC + 1
            End If
        Next i
 
        For i = LBound(RAPP, 1) To UBound(RAPP, 1)
            If MonControl.Name = RAPP(i) Then
               If MonControl = True Then Total_RAPP = Total_RAPP + 1
            End If
        Next i
 
         For i = LBound(LANG, 1) To UBound(LANG, 1)
            If MonControl.Name = LANG(i) Then
               If MonControl = True Then Total_LANG = Total_LANG + 1
            End If
        Next i
 
        For i = LBound(PRAX, 1) To UBound(PRAX, 1)
            If MonControl.Name = PRAX(i) Then
               If MonControl = True Then Total_PRAX = Total_PRAX + 1
            End If
        Next i
 
 
    Next MonControl
 
 
.Total_OS = Total_OS
.Total_OT = Total_OT
.Total_APP = Total_APP
.Total_CALC = Total_CALC
.Total_RAPP = Total_RAPP
.Total_LANG = Total_LANG
.Total_PRAX = Total_PRAX
.Total_MMSE = Total_OT + Total_OS + Total_APP + Total_CALC + Total_RAPP + Total_LANG + Total_PRAX
 
Worksheets("Result").Range("B3").Value = Val(.Total_OT)
Worksheets("Result").Range("B4").Value = Val(.Total_OS)
Worksheets("Result").Range("B5").Value = Val(.Total_APP)
Worksheets("Result").Range("B6").Value = Val(.Total_CALC)
Worksheets("Result").Range("B7").Value = Val(.Total_RAPP)
Worksheets("Result").Range("B8").Value = Val(.Total_LANG)
Worksheets("Result").Range("B9").Value = Val(.Total_PRAX)
Worksheets("Result").Range("B10").Value = Val(.Total_MMSE)
 
 
End With
 
ActiveDocument.Bookmarks("Signet10").Range.Text = Worksheets("result").Range("B3").Value
 
End Sub