Word 2010 macro: Set a checkbox to "checked" ?

Posted on 2012-08-27
Last Modified: 2012-08-27
I presume it's simple, but I'm mentally stuck o that one:

This piece of macro code in MS Word 2010 should find the first checkbox in the current document (it does) and just set it to checked (that fails):

For Each f In ActiveDocument.Fields
        If f.Type = wdFieldFormCheckBox Then
            f.Result = True
            Exit For
        End If
Next f

Open in new window

The line f.Result = True fails with "Incompatible types". What's wrong, or, to be precise:

How can I set the checkbox to "checked" ?

(The object f contains not property Value ....)
Question by:frankhelk
    LVL 76

    Accepted Solution

    You need to use the Checkbox property. Incidentally, there is a FormField type and a FormFields collection
    Sub setcheck()
    Dim f As FormField
    For Each f In ActiveDocument.FormFields
            If f.Type = wdFieldFormCheckBox Then
                f.CheckBox.Value = True
                Exit For
            End If
    Next f
    End Sub

    Open in new window

    LVL 13

    Author Closing Comment

    Resolved it on my own in the meantime (sorry), but you've hit the spot.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
    A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
    This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now