#1   Report Post  
Posted to microsoft.public.word.docmanagement
Lisa Mazzanti Lisa Mazzanti is offline
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
conditional checkbox?? Iragalam Microsoft Word Help 2 June 20th 07 10:19 PM
Conditional Formating Manny Tables 2 May 28th 07 08:54 PM
Conditional merging a field and formating it [email protected] Mailmerge 1 April 7th 06 08:02 PM
Formating Text changes formating of entire document Ritesh Kumar Microsoft Word Help 1 July 6th 05 11:55 PM
Conditional Slash Similar to Conditional Hyphen? Oliver St Quintin Page Layout 7 May 10th 05 09:41 PM


All times are GMT +1. The time now is 10:18 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"