none
Clear checkboxes/checkmarks in Word content control fields RRS feed

  • Question

  • How can I clear all the checkboxes in my document that are checked. I have tried the following code and it executes with no errors but it doesn't clear the boxes.

    Do you know why this code isn't working?  Can you provide alternate code?  Thanks in advance.

    Sub ClearCheckBoxes()

        Dim ffld As FormField
        For Each ffld In ActiveDocument.FormFields
            If ffld.Type = wdFieldFormCheckBox Then
                ffld.CheckBox.Value = False
            End If
        Next ffld
    End Sub

    Friday, May 12, 2017 11:07 AM

Answers

  • Hi Falcios

    In the subject of your post you speak of "content control", so I guess you should adjust your code like this:

    Sub ClearCheckBoxes()
        Dim cc As ContentControl
        For Each cc In ActiveDocument.ContentControls
            If cc.Type = wdContentControlCheckBox Then
                cc.Checked = False
            End If
        Next cc
    End Sub

    Hope this helps.

    Cheers, Luca

    • Marked as answer by falcios Friday, May 12, 2017 12:28 PM
    Friday, May 12, 2017 11:38 AM

All replies

  • Hi Falcios

    In the subject of your post you speak of "content control", so I guess you should adjust your code like this:

    Sub ClearCheckBoxes()
        Dim cc As ContentControl
        For Each cc In ActiveDocument.ContentControls
            If cc.Type = wdContentControlCheckBox Then
                cc.Checked = False
            End If
        Next cc
    End Sub

    Hope this helps.

    Cheers, Luca

    • Marked as answer by falcios Friday, May 12, 2017 12:28 PM
    Friday, May 12, 2017 11:38 AM
  • Thanks so much.  Worked great.
    • Marked as answer by falcios Friday, May 12, 2017 11:47 AM
    • Unmarked as answer by falcios Friday, May 12, 2017 12:29 PM
    Friday, May 12, 2017 11:47 AM
  • Hi falcios,

    I'm afraid you have marked on a wrong post. 

    Friday, May 12, 2017 12:27 PM