View Single Post
 
Old 04-04-2013, 03:29 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Try the following, which is based on the code in your link:
Code:
Sub OnExitDD()
Dim StrRslt As String, StrPwd As String
Dim lRow As Long, lCol As Long
lRow = 1: lCol = 1: StrPwd = "Password"
With ActiveDocument
  If .ProtectionType = wdAllowOnlyFormFields Then .Unprotect , StrPwd
  StrRslt = .FormFields("ColorPicker").Result
  With .Tables(1).Cell(lRow, lCol).Range
    Select Case StrRslt
      Case "Red"
        .Font.Color = wdColorDarkRed
        .Shading.BackgroundPatternColor = wdColorPink
      Case "Blue"
        .Font.Color = wdColorDarkBlue
        .Shading.BackgroundPatternColor = wdColorLightBlue
      Case "Green"
        .Font.Color = wdColorDarkGreen
        .Shading.BackgroundPatternColor = wdColorBrightGreen
      Case Else
      'Do Nothing
    End Select
  End With
  .Protect wdAllowOnlyFormFields, True, NoReset:=True, Password:=StrPwd
End With
End Sub
Note: The code is designed to update the colours of the first cell in the first table in the document. You can change the table & cell references via the various 1s in the code.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]