Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-29-2023, 04:02 AM
chris.james chris.james is offline CHange colour of text box if has a tick or a X Windows 10 CHange colour of text box if has a tick or a X Office 2021
Novice
CHange colour of text box if has a tick or a X
 
Join Date: Sep 2023
Posts: 1
chris.james is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 10-01-2023, 12:50 AM
Guessed's Avatar
Guessed Guessed is offline CHange colour of text box if has a tick or a X Windows 10 CHange colour of text box if has a tick or a X Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
CHange colour of text box if has a tick or a X 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
CHange colour of text box if has a tick or a X Quickest way to change text to Arial size 11 specific colour BlueClearSky Word 6 11-22-2013 03:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:47 AM.


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