Consulting

Results 1 to 2 of 2

Thread: Recording Macro with a Checkbox?

  1. #1
    VBAX Newbie
    Joined
    Oct 2014
    Posts
    1
    Location

    Recording Macro with a Checkbox?

    I'm using a Word template that the user will complete and then save to create the document. I want to have checkboxes in the document that the user can turn on/off as needed for each version they are going to save.

    I'm reading an external file and based on its data contents the checkboxes will be initially set on and off accordingly.

    My issue is with the CHECKBOXES in the DEVELOPER ribbon. I typically "write code" by recording a macro. However, when I start a macro recording, it will not let me "check" the CHECKBOX. If I pause the macro, then I can check it on and off.

    I've tried to research this issue and have seen something about LEGACY toolkit. What are these?

    I'm sure it is something simple but I can't seem to conquer it.

    Any assistance would be appreciated.

    AGI_MEG

  2. #2
    It is a fact of life that the macro recorder will not record all commands, and it doesn't often use the most efficient code. If you want to insert a check box using VBA you will have to do it manually. You didn't say what kind of check box, but assuming that you want to insert a legacy form field check box at the cursor position the code would be

    Dim oFld As FormField
        Set oFld = ActiveDocument.FormFields.Add(Selection.Range, wdFieldFormCheckBox)
        oFld.CheckBox.Value = True 'or False
    I don't know which Legacy toolkit you are referring to, but it may be Greg Maxey's useful ribbon addition http://gregmaxey.mvps.org/word_tip_p..._controls.html. However this will not affect the issue regarding the macro recorder.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

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