#1
|
|||
|
|||
CHange colour of text box if has a tick or a X
HI.
I use vba on excel fairly regularly but just started to use on word and ill be honest im confused on what i thought would be a basic thing to do. I have lots of checkboxes in a word doc and when i click on a checkbox it brings up a tick and a x. So far so good with no vba. Now what i want is that when the checkbox is clicked if this brings up the tick the checkbox goes green and if it brings up a x the checkbox goes red. I found the following code but it isnt performing how i hoped. Code:
Private Sub Document_ContentControlOnExit(ByVal aCC As ContentControl, Cancel As Boolean) Select Case aCC.Title Case "Test" If aCC.Checked = True Then aCC.Range.Paragraphs(1).Range.Font.ColorIndex = wdGreen Else aCC.Range.Paragraphs(1).Range.Font.ColorIndex = wdRed End If End Select End Sub |
#2
|
||||
|
||||
There are a lot of assumptions required to allow this to work for you.
1. You are using Content Control checkboxes, not legacy fields 2. The macro has to go in the ThisDocument module 3. The title of the checkbox is "Test" 4. You move the cursor after setting the value (the macro won't run until you 5. The Content Control has both a checked symbol and an unchecked symbol set in the properties.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Change "fill" text colour to no colour | darkmaster006 | Word VBA | 15 | 08-22-2023 10:10 AM |
Change Text Colour/Box Shade if CheckBox is marked | cavals07 | Word VBA | 7 | 01-30-2023 11:05 AM |
Change text colour for content control labels? | Toe | Word | 1 | 01-17-2019 08:45 AM |
Change Text Colour in Cell Based on Text in Same Cell | PMC11 | Word VBA | 1 | 11-14-2017 09:15 PM |
Quickest way to change text to Arial size 11 specific colour | BlueClearSky | Word | 6 | 11-22-2013 03:34 PM |