Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2019, 01:44 PM
valaden valaden is offline Changing line background color depending on the content control value Windows 10 Changing line background color depending on the content control value Office 2016
Novice
Changing line background color depending on the content control value
 
Join Date: Nov 2019
Posts: 1
valaden is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 11-21-2019, 08:11 PM
macropod's Avatar
macropod macropod is offline Changing line background color depending on the content control value Windows 7 64bit Changing line background color depending on the content control value Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See: Change color according with dropdown selection. Simply change all instances of 'Cells' to 'Rows'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing line background color depending on the content control value 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
Changing line background color depending on the content control value 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:05 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