change color of cell based upon form drop down selection

T

Tim Doyle

Is it possible to change the background color (or font) of a cell
conditionally based upon a selection made from a drop down box within another
cell of the same table?
 
G

Greg Maxey

Tim.

Yes.

You create and assign a macro to run on exit from the formfield.

Let's say you have a dropdown with the values "Red" "Blue" and "Green."
The formfield has a bookmark name of "ColorPicker"

Sub OnExitDD()
ActiveDocument.Unprotect
Select Case ActiveDocument.FormFields("ColorPicker").Result
Case "Red"
ActiveDocument.Tables(1).Cell(?, ?).Range.Font.Color = wdColorRed
ActiveDocument.Tables(1).Cell(?,
?).Range.Shading.BackgroundPatternColor = wdColorDarkRed
Case "Blue"
'Like above except differenct colors
Case "Whatever"
'Like above
Case Else
'Do Nothing
End Select
ActiveDocument.Protect wdAllowOnlyFormFields, True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top