Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-04-2017, 12:23 PM
warbird warbird is offline VBA Assign Checkbox Content Control Symbols Windows 7 64bit VBA Assign Checkbox Content Control Symbols Office 2010 64bit
Novice
VBA Assign Checkbox Content Control Symbols
 
Join Date: Jun 2015
Posts: 13
warbird is on a distinguished road
Question 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!
Reply With Quote
  #2  
Old 12-04-2017, 03:48 PM
gmaxey gmaxey is offline VBA Assign Checkbox Content Control Symbols Windows 7 32bit VBA Assign Checkbox Content Control Symbols Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,427
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 12-05-2017, 07:20 AM
warbird warbird is offline VBA Assign Checkbox Content Control Symbols Windows 7 64bit VBA Assign Checkbox Content Control Symbols Office 2010 64bit
Novice
VBA Assign Checkbox Content Control Symbols
 
Join Date: Jun 2015
Posts: 13
warbird is on a distinguished road
Default

Thank You! I found most of the pieces but had a hard time with the syntax
Reply With Quote
  #4  
Old 01-16-2018, 12:26 PM
warbird warbird is offline VBA Assign Checkbox Content Control Symbols Windows 7 64bit VBA Assign Checkbox Content Control Symbols Office 2010 64bit
Novice
VBA Assign Checkbox Content Control Symbols
 
Join Date: Jun 2015
Posts: 13
warbird is on a distinguished road
Default

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
It worked the first time or two but now gives a "Type Mismatch" error. It's not critical to the document function, just a loose end that doesn't make sense.

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.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Assign Checkbox Content Control Symbols One Content Control Checkbox checks another Content Control Checkbox DEsh Word VBA 2 10-06-2017 08:23 PM
VBA Assign Checkbox Content Control Symbols Content control checkbox calculations allikat305 Word Tables 5 11-22-2016 11:20 PM
VBA Assign Checkbox Content Control Symbols Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
VBA Assign Checkbox Content Control Symbols Replace checkbox symbol with check box content control canadansk Word VBA 5 04-01-2015 08:21 AM
VBA Assign Checkbox Content Control Symbols Assign a value to a Content Control SuzeG Word VBA 10 12-08-2013 08:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft