Whats the text in previous formfield

C

Cifly

Hey NG

I try to construct a function, at formfield exit, with which i can change
the color of the text in the formfield, based on the text in it at exit.

Eg. In my formfield, i have two different numbers "1" and "2". If the text,
at exit, is "1", then the text (the number 1) should be blue. If it is 2,
then the color of the number should change to purple.

Does anyone have a solution, code, for this maneuvre?

Thx in advance,
Cifly
 
D

Doug Robbins - Word MVP

Run a macro containing the following code on exit from the formfield:

With ActiveDocument.FormFields("Text1")
If .result = 1 Then
ActiveDocument.Unprotect
.Range.Font.Color = wdColorBlue
Else
ActiveDocument.Unprotect
.Range.Font.Color = wdColorPlum
End If
ActiveDocument.Protect wdAllowOnlyFormFields, noreset
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

Cifly

Doug said:
Run a macro containing the following code on exit from the formfield:

With ActiveDocument.FormFields("Text1")
If .result = 1 Then
ActiveDocument.Unprotect
.Range.Font.Color = wdColorBlue
Else
ActiveDocument.Unprotect
.Range.Font.Color = wdColorPlum
End If
ActiveDocument.Protect wdAllowOnlyFormFields, noreset
End With

Great. Thx. It did the trick!

Have a great weekend.

Cifly
 

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