A family of Microsoft word processing software products for creating web, email, and print documents.
If you title each of your content controls in the table according to their classification (i.e. ), and add text content controls using the same titles to each of the output lines at the end of the document, you can use a macro like:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim StrTitle As String, i As Long, j As Long, k As Long, r As Long
With CCtrl
If .Range.Information(wdWithInTable) = False Then Exit Sub
If ActiveDocument.Range(0, .Range.End).Tables.Count = 1 Then Exit Sub
StrTitle = .Title: i = 0: k = 0
With .Range.Tables(1)
For r = 1 To .Rows.Count
With .Cell(r, 3).Range.ContentControls(1)
If .Title = StrTitle Then
If .ShowingPlaceholderText = False Then
k = k + 4
For j = 1 To .DropdownListEntries.Count
If .DropdownListEntries(j).Text = .Range.Text Then
i = i + .DropdownListEntries(j).Value: Exit For
End If
Next
End If
End If
End With
Next
End With
End With
With ActiveDocument
For r = .ContentControls.Count To 1 Step -1
With .ContentControls(r)
If .Range.Information(wdWithInTable) = True Then Exit For
If .Title = StrTitle Then
.LockContents = False
If i = 0 Then
.Range.Text = ""
Else
.Range.Text = i & " van een mogelijke " & k & " (" & Format(i / k, "0%") & ")"
End If
.LockContents = True
Exit For
End If
End With
Next
End With
Application.ScreenUpdating = True
End Sub
The above macro should be placed in the 'ThisDocument' code module of your document or (preferably) its template.
A fully-functional macro-enabled copy of your document is available here: