View Single Post
 
Old 10-15-2015, 03:49 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

As coded, the macro in the link is for just a single table cell. To work with multiple dropdowns, you could use code like:
Code:
Dim lTbl As Long, lRow As Long, lCol As Long, lClr As Long
Const StrPwd As String = ""
 
Sub ConditionalFormat()
With ActiveDocument
  If .ProtectionType = wdAllowOnlyFormFields Then .Unprotect , StrPwd
  .Tables(lTbl).Cell(lRow, lCol).Range.Shading.BackgroundPatternColor = lClr
  .Protect wdAllowOnlyFormFields, True, NoReset:=True, Password:=StrPwd
End With
End Sub
called by an on-exit macro attached to each formfield coded along the lines of:
Code:
Sub DD1Fmt()
With ActiveDocument.FormFields("Dropdown1")
  lTbl = ActiveDocument.Range(0, .Range.End).Tables.Count
  lRow = .Range.Cells(1).RowIndex
  lCol = .Range.Cells(1).ColumnIndex
  Select Case .Result
    Case "Unknown": lClr = wdColorPink
    Case "Yes": lClr = wdColorLightBlue
    Case "No": lClr = wdColorBrightGreen
    Case Else: lClr = wdColorYellow
  End Select
  Call ConditionalFormat
End With
End Sub
Simply change this latter sub's name and dropdown reference for each calling dropdown.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote