[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2012-08-27
Medium Priority
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

GrahamSkan earned 2000 total points
ID: 38336000
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 14

Author Closing Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
Suggested Courses

834 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