View Single Post
 
Old 08-01-2016, 11:42 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
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

I think you only need one macro
Code:
Sub ColorDropDown()
  Dim sText As String, oFld As FormField
  With ActiveDocument
    If .ProtectionType <> wdNoProtection Then .Unprotect Password:=""
    For Each oFld In .FormFields
      Select Case oFld.Result
        Case "G"
          oFld.Range.Font.Color = wdColorBrightGreen
          oFld.Range.Shading.BackgroundPatternColor = wdColorBrightGreen
        Case "Y"
          oFld.Range.Font.Color = wdColorYellow
          oFld.Range.Shading.BackgroundPatternColor = wdColorYellow
        Case "R"
          oFld.Range.Font.Color = wdColorRed
          oFld.Range.Shading.BackgroundPatternColor = wdColorRed
      End Select
    Next oFld
    .Protect Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
  End With
End Sub
If your document has other formfields in it then you might need the code to restrict itself to a defined range (bookmarked) or something similar but you don't need to know every named formfield.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote