#1
|
|||
|
|||
VBA Assign Checkbox Content Control Symbols
I have a Word doc with a series of checkbox content controls using the code that makes them operate like the old option groups (big thanks to Greg Maxey). It all worked nicely until...
Recently I have hit some (unnamed) errors with this document that have locked up Word. When the document is recovered all of the check box symbols have been changed to either a narrow vertical rectangle (both checked & unchecked) or an "R" and "L" (British pound symbol). The first time I looked for code examples that would change it back but I couldn't find anything I could understand. I gave up the search and fixed them all manually using the dialog boxes. (my form contains more than 200 check boxes). It just happened a second time! To be sure I get the look I want I think I need to add code that assigns these symbols each time the document loads. I know there is a better way but it seems to be just a little over my head. There are two variations of checkbox CC's on the form. One uses the 82 & 163 symbols and one uses the 152 & 153 symbols (both "Wingdings 2"). The former are not identified (but could be) because the don't really do anything. The latter are all tagged "RateDot" (these trigger OnEnter & OnExit code). Help! |
#2
|
|||
|
|||
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 12/4/2017 Dim oCC As ContentControl For Each oCC In ActiveDocument.Range.ContentControls If oCC.Type = wdContentControlCheckBox And oCC.Title = "RateDot" Then oCC.SetCheckedSymbol CharacterNumber:=82, Font:="Wingdings 2" oCC.SetUncheckedSymbol CharacterNumber:=163, Font:="Wingdings 2" End If Next lbl_Exit: Exit Sub End Sub |
#3
|
|||
|
|||
Thank You! I found most of the pieces but had a hard time with the syntax
|
#4
|
|||
|
|||
Using Greg's example I created this:
Code:
Private Sub SetCheckSymbol() Dim oCC As ContentControl For Each oCC In ActiveDocument.Range.ContentControls If oCC.Type = wdContentControlCheckBox Then If oCC.Tag = "RateDot" Then oCC.SetCheckedSymbol CharacterNumber:=152, Font:="Wingdings 2" oCC.SetUncheckedSymbol CharacterNumber:=153, Font:="Wingdings 2" ElseIf oCC.Tag = "ChkBox" Or "CarryCk" Then oCC.SetCheckedSymbol CharacterNumber:=82, Font:="Wingdings 2" oCC.SetUncheckedSymbol CharacterNumber:=163, Font:="Wingdings 2" End If End If Next Exit Sub End Sub I have streamlined most of the code and replaced some of the VBA with XML binding. My form has been much more stable and responsive. It hasn't locked up the whole application recently. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
One Content Control Checkbox checks another Content Control Checkbox | DEsh | Word VBA | 2 | 10-06-2017 08:23 PM |
Content control checkbox calculations | allikat305 | Word Tables | 5 | 11-22-2016 11:20 PM |
Clicking the selected Content Control checkbox returns wrong control in vba event | DougsGraphics | Word VBA | 2 | 06-24-2015 07:31 AM |
Replace checkbox symbol with check box content control | canadansk | Word VBA | 5 | 04-01-2015 08:21 AM |
Assign a value to a Content Control | SuzeG | Word VBA | 10 | 12-08-2013 08:04 AM |