View Single Post
 
Old 09-10-2018, 12:48 PM
andreamills127 andreamills127 is offline Windows 10 Office v. X
Novice
 
Join Date: Sep 2018
Posts: 2
andreamills127 is on a distinguished road
Default

Hi, I have just managed to colour code a drop down list in Word with a macro (even though I've never done anything like that before!) but can I have two different drop down lists (called different names) with different colour coding in the same document?

I used this for the first one:

Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
With ContentControl.Range
    If ContentControl.Title = "CC" Then
        Select Case .Text
            Case "NC"
                .Cells(1).Shading.BackgroundPatternColor = wdColorRed
            Case "OBS"
                .Cells(1).Shading.BackgroundPatternColor = wdColorLightOrange
            Case "GP"
                .Cells(1).Shading.BackgroundPatternColor = wdColorLime
            Case "REC"
                .Cells(1).Shading.BackgroundPatternColor = wdColorSkyBlue
            Case "NI"
                .Cells(1).Shading.BackgroundPatternColor = wdColorGray15
            Case Else
                .Cells(1).Shading.BackgroundPatternColor = wdColorAutomatic
        End Select
    End If
End With
End Sub
I've tried copying and pasting this into the same module and another one (changing the title name) but I'm obviously doing something wrong?

Last edited by macropod; 09-10-2018 at 02:56 PM. Reason: Added code tags & formatting