Conditional Formatting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Excel has a lovely feature where I can set up conditional formatting -- if
the contents of a cell meet certain criteria, the formatting of that cell
will change according to the rules I set.

I would like to do this in Word, although I am aware that there is no
feature called "Conditional Formatting" so I'm hoping to jerry-rig something.

Specifically, I have a form om which there is a a drop-down field in a table
cell. Ideally what I would like to happen is for the table cell fill to
change color depending on the item selected. I would settle for having the
text change color.

I'm not experienced writing VBA, but I know enough to copy & paste code &
attach the macro to the form field. So, any ideas?
 
TL

Something like this

Sub EvaluateFormFieldContent()

ActiveDocument.Unprotect
With ActiveDocument
If .FormFields("DropDown1").Result = "Yes" Then
.Tables(1).Cell(1, 1).Shading.BackgroundPatternColor = wdColorBlue
Else
.Tables(1).Cell(1, 1).Shading.BackgroundPatternColor = wdColorAutomatic
End If
End With
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset = False
End Sub
 
TL,

Excuse the temporary insanity. Replace the line

ActiveDocument.Protect wdAllowOnlyFormFields, NoReset = False

with

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
 

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

Similar Threads


Back
Top