Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-11-2018, 01:42 AM
gsbpxw gsbpxw is offline Code to change highlight on content control automatically Windows 7 32bit Code to change highlight on content control automatically Office 2010 32bit
Novice
Code to change highlight on content control automatically
 
Join Date: Jun 2018
Posts: 3
gsbpxw is on a distinguished road
Default Code to change highlight on content control automatically

I have code which will change the colour on a content control drop down when the macro isrun, but I would like it to run automatically when I exit the content control, please could you advise?

Sub AddColour()

Dim cc1 As ContentControl
Set cc1 = ActiveDocument.SelectContentControlsByTitle("Ratin g").Item(1)
If cc1.Title = "Rating" Then
Select Case True
Case cc1.Range.Text = "Feasible"
cc1.Range.Shading.BackgroundPatternColor = wdColorGreen
Case cc1.Range.Text = "Less Feasible"
cc1.Range.Shading.BackgroundPatternColor = wdColorYellow
Case cc1.Range.Text = "Not Feasible"
cc1.Range.Shading.BackgroundPatternColor = wdColorRed
Case Else
cc1.Range.Shading.BackgroundPatternColor = wdColorAutomatic
End Select
End If
End Sub
Reply With Quote
 

Tags
content control, vba change colour



Similar Threads
Thread Thread Starter Forum Replies Last Post
Table with content control drop down - change font DebA Word 3 04-29-2018 09:07 PM
Code to change highlight on content control automatically Is there a way to anchor drop-down content control boxes so entering text doesn't change formatting? TzarChasm Word 7 04-14-2016 06:28 PM
Code to change highlight on content control automatically Code to Sum Column of Content Control Values In Specific Tables? warbird Word VBA 2 07-13-2015 05:44 AM
a code that can change the layout for the headers and footers on each page automatically gmbh Word VBA 1 07-31-2014 04:24 AM
Code to change highlight on content control automatically Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:42 PM.


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