Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Oct 2003
    Location
    Toronto, Ontario, Canada
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populate Word document form checkbox, etc. (XP)

    I have a document template someone else created in Word containing Form checkboxes (from the Forms toolbar, not the Controls toolbar). Its a fairly complex form and I have created a VBA "wizard" with a UserForm and code to collect all the data. I now need to put the information in the "new" document. I have no problem moving to a particular bookmark and dropping text data at that position, but I am having trouble figuring out how to set the Form checkboxes to a True value based on the VBA code. I have tried with the document protected and unprotected - no joy. How do I set checkboxes, radiobuttons in the document? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,808
    Thanks
    4
    Thanked 235 Times in 217 Posts

    Re: Populate Word document form checkbox, etc. (XP

    See if you have more luck with this syntax
    ActiveDocument.FormFields("Check2").CheckBox.Value = True
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Lounger
    Join Date
    Oct 2003
    Location
    Toronto, Ontario, Canada
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate Word document form checkbox, etc. (XP

    This is the syntax I have been trying. It doesn't cause any errors, but it doesn't seem to have any effect either. The two code snippets I have been using are:

    If Epmo2ProjectInitiation.QuickScored.Value = True Then
    ActiveDocument.FormFields("BMQuickScoreDone").Chec kBox.Value = True
    End If

    and

    Private Sub SetTo(WhereTo As String, WhatTo As String, BoldTo As Boolean)
    Selection.GoTo What:=wdGoToBookmark, Name:=WhereTo
    Options.ReplaceSelection = False
    With Selection
    .Font.Bold = BoldTo
    .TypeText Text:=WhatTo
    End With
    End Sub


    The SetTo sub works fine, but it is just dumping text onto the document at a given bookmark. I can't figure why the first piece doesn't seem to have an effect.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Populate Word document form checkbox, etc. (XP

    The code

    ActiveDocument.FormFields("BMQuickScoreDone").Chec kBox.Value = True

    should work. Set a breakpoint on the line above it (press F9). The code will pause there when you run it. You can then single step through the code by pressing F8, and inspect the value of variables and controls by hovering the mouse pointer over them in the code. See if the line to set the form checkbox is actually executed.

  5. #5
    Lounger
    Join Date
    Oct 2003
    Location
    Toronto, Ontario, Canada
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate Word document form checkbox, etc. (XP

    Thanks Hans. It turns out that it does work after all. The breakpoints showed that the conditional never got triggered. Have not used breakpoints and the debug stuff before. Thanks for the assist. <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •