Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Conditional Formating
I am creating a form in Word 2003 and wondering if you can use conditional
formating. I have a number field and when a negative number is entered I want it to be in red (like you can do in excel) -- L. Mazzanti |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Conditional Formating
Lisa Mazzanti wrote:
I am creating a form in Word 2003 and wondering if you can use conditional formating. I have a number field and when a negative number is entered I want it to be in red (like you can do in excel) No, Word doesn't do conditional formatting like Excel. If embedding a cell from an Excel worksheet in your Word document doesn't appeal to you, then you'll need a macro like the following, assigned as the exit macro of the form field in question (or more than one form field): Sub FormatNegative() Dim rslt As String If Selection.Bookmarks.Count Then With Selection.Bookmarks(1).Range rslt = .FormFields(1).Result If ActiveDocument.ProtectionType wdNoProtection Then ActiveDocument.Unprotect End If If IsNumeric(rslt) Then If Val(rslt) 0 Then .FormFields(1).Range.Font.Color = wdColorRed Else .FormFields(1).Range.Font.Color = wdColorBlack End If ' Else ' .FormFields(1).Range.Font.Color = wdColorBrightGreen End If ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End With End If End Sub See http://www.gmayor.com/installing_macro.htm if needed. The two lines that start with a single quote are comments. If you want entries that aren't valid numbers to be highlighted, remove the single quotes. Of course, you can pick a different color than bright green. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
conditional checkbox?? | Microsoft Word Help | |||
Conditional Formating | Tables | |||
Conditional merging a field and formating it | Mailmerge | |||
Formating Text changes formating of entire document | Microsoft Word Help | |||
Conditional Slash Similar to Conditional Hyphen? | Page Layout |