How to select a checkbox in Microsoft Word from VB6

al4629740
al4629740 used Ask the Experts™
on
I am using VB6 to access a Microsoft Word template.  What I am perplexed on what to do is how to select a checkbox field as you can see from the attached image.  Currently Quarter 2 is selected.  How can I select Quarter 3.  I can bookmark the field, but I don't know the syntax for selection and checking the field.  Any help is appreciated.  


Here is some example code I am currently using in the document if that helps.

            objMSWord.ActiveDocument.Bookmarks(ObjectiveNumber).Select
            objMSWord.Selection.TypeText "ACTIVITY: " & rec!ActivityName & " - " & rec!ActivityType & "    " & rec!ActivityOther & vbCrLf
            objMSWord.Selection.TypeText "Identified Need: " & rec!Need & "    " & rec!NeedOther & vbCrLf
            objMSWord.Selection.TypeText "Objective Addressed: " & rec!Objectives & vbCrLf
            objMSWord.Selection.TypeText "Stated Strategy: " & rec!Strategy & vbCrLf
            objMSWord.Selection.TypeText "Outcome: " & rec!Outcome & vbCrLf
            objMSWord.Selection.TypeText "Narrative Summary: " & rec!Narrative & vbCrLf
            objMSWord.Selection.TypeText "-----------------------------" & vbCrLf & vbCrLf

Open in new window

example.jpg
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
GrahamSkanRetired
Top Expert 2012

Commented:
Hi,
What sort of checkbox?  Is it a Form Field, an Active X or a Content Control? If not in developer mode, all three types of checkbox look very similar.
The code seems to be adding text at a bookmark, so that doesn't help very much.

Author

Commented:
I think form fields
GrahamSkanRetired
Top Expert 2012

Commented:
To use the document, do you have to protect it for 'Filling in forms'?
Retired
Top Expert 2012
Commented:
If you simply want to check it or uncheck it, you can set the Value of the CheckBox property to true or false
Option Explicit
Sub FFCheckBox()
    Dim ffcb As FormField
    
    Set ffcb = ActiveDocument.FormFields("Check1")
    With ffcb
        If .CheckBox.Value = False Then
            .CheckBox.Value = True
        Else
            .CheckBox.Value = False
        End If
    End With
End Sub

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial