#1
|
|||
|
|||
Changing line background color depending on the content control value
Hello,
I have been working on having some automation to the tables at my new workplace. Basically one content control(Amiante1) is used to select whether abestos is present or not and if it is, what kind of asbestos is present. Depending on the first content control, the 2nd one(Conc1) either picks a concentration value or N/A. I've been trying to figure out if there was a way to change the background color of the entire line to yellow only if a type of asbestos is selected. Here is what I've been using, inspired by another script I found here and butchered to get something that works for me! 1 to 3 are placeholder text/Not detected/not analyzed. 4 to 7 are types of asbestos. Any help would be greatly appreciated! Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean) Application.ScreenUpdating = False Dim oCC As ContentControl Dim i As Integer With CCtrl Select Case .Title Case "Amiante1" Set oCC = ActiveDocument.SelectContentControlsByTitle("Conc1").Item(1) If .ShowingPlaceholderText = False Then For i = 1 To 3 If .DropdownListEntries(i) = .Range.Text Then oCC.Range.Text = .DropdownListEntries.Item(i).Value Exit For End If Next i Else oCC.Range.Text = "" End If Case Else End Select End With lbl_Exit: Set oCC = Nothing |
#2
|
||||
|
||||
See: Change color according with dropdown selection. Simply change all instances of 'Cells' to 'Rows'.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Changing color of instructional text in a content control box | Document Specialist | Word | 2 | 08-17-2018 05:25 AM |
HELP! Excel background color changing unexpectedly | Doug Needham | Excel | 0 | 12-08-2016 08:22 AM |
changing background color | kiv | Word | 7 | 09-17-2015 02:28 AM |
Control Time Calculaiton depending on whether line is running or not. | rdperry11 | Excel | 4 | 02-24-2015 09:35 PM |
Changing Word Background Color | lrmaps.423 | Word | 10 | 02-24-2014 05:22 PM |