View Single Post
 
Old 04-27-2018, 06:38 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,994
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

You were almost there. Two things:
- Capitalisation is important. If you don't match the same capitalisation then your code would fail. I've added the UCase to your code to avoid this problem
- You need to specify the RANGE where you want to colour the font. This code now colours the entire cell's range but you may have been happy just doing the range of the Content Control (in which case .Font.Color = wdColorRed would have been enough
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  If UCase(ContentControl.Title) = "ACTION" Then
    With ContentControl.Range
      Select Case UCase(.Text)
      Case "URGENT"
        .Cells(1).Range.Font.Color = wdColorRed
      Case "FOLLOW"
        .Cells(1).Range.Font.Color = wdColorOrange
      Case "INFORMATION"
        .Cells(1).Range.Font.Color = wdColorGreen
      End Select
    End With
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote