"Conditional formatting" in Word drop-down form fields

G

Guest

Word 2000, Windows XP.

Hi,

I'm working with drop-down form fields placed in word table cells. Each
drop-down formfield has the selections red, yellow and green. I'm looking for
the code to the on exit macro so that the color of the cell turn red if red
is selected and so on...after the selection it should go to the next form
field.

The document should unprotect, format the cell, then protect again without
resetting and jump to the next form field.

Thanks in advance...
 
C

Cindy M.

Hi =?Utf-8?B?QmVuamFtaW4=?=,
I'm working with drop-down form fields placed in word table cells. Each
drop-down formfield has the selections red, yellow and green. I'm looking for
the code to the on exit macro so that the color of the cell turn red if red
is selected and so on...after the selection it should go to the next form
field.

The document should unprotect, format the cell, then protect again without
resetting and jump to the next form field.
Yes. Have you tried recording these actions in a macro? Do so, copy the result
into a reply, and explain what part doesn't work. (We can then show you how to
make the color selection.)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
G

Guest

I'm not sure how to record a macro when the form protection has been activated.

The macro I've been trying (see below) seems to be working when I tab
through the cells, but if I jump to new form fields using the mouse, Word
crashes at a point:

Sub ColorField()

ProtectDoc 'macro to protect and unprotect

Selection.SelectCell
DropdownName = Selection.FormFields(1).Name

If ActiveDocument.FormFields(DropdownName).Result = "Red" Then
With Selection.Cells
With .Shading
.BackgroundPatternColor = wdColorRed
End With
End With
ElseIf ActiveDocument.FormFields(DropdownName).Result = "Yellow" Then
..
..
..
..
End If

ProtectDoc

ActiveDocument.FormFields(DropdownName).Select

End Sub



Sub ProtectDoc()

If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True
Else
ActiveDocument.Unprotect
End If

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