Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.word.tables
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default form - field shaded when blank, unshaded when filled in

On Tue, 26 Jan 2010 15:04:38 -0800, Aliza Berger-Cooper wrote:

I want to create a fill-in form in Word 2003, with text fields. I would like to initially shade the fill-in fields, and after the person fills one in, it would automatically go to unshaded. The idea is that the ones they still need to fill in would stand out as shaded (or, better yet, colored).

I would also like the same advice regarding a table cell in an ordinary document (NOT in a fill-in form)?



I assume this requires macros. I saw a somewhat similar thread on checkboxes he
http://www.eggheadcafe.com/software/...e-of-chec.aspx

But I am not experienced enough with macros to be sure how to adapt this.

Thanks very much in advance!

Aliza in Jerusalem


Submitted via EggHeadCafe - Software Developer Portal of Choice
Create the Signature of XML file
http://www.eggheadcafe.com/tutorials...ture-of-x.aspx


For text form fields, you can put this macro in the form template
(change the colors as desired):

Sub FormExit()
Dim fld As FormField
ActiveDocument.Unprotect
If Selection.Bookmarks.Count 0 Then
Set fld = ActiveDocument.FormFields( _
Selection.Bookmarks( _
Selection.Bookmarks.Count).Name)
End If
If Trim(fld.Result) = "" Then
fld.Range.Shading _
.BackgroundPatternColor = wdColorYellow
Else
fld.Range.Shading _
.BackgroundPatternColor = wdColorWhite
End If
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End Sub

Assign this macro as the exit macro of each text form field. To have
each new document start with the fields colored, also put in this
macro:

Sub AutoNew()
Dim fld As FormField
With ActiveDocument
.Unprotect
For Each fld In .FormFields
fld.Range.Shading.BackgroundPatternColor = _
wdColorYellow
Next
.Protect Type:=wdAllowOnlyFormFields
End With
End Sub

This sort of thing works for form fields because you can assign an
exit macro that runs automatically when you exit the field. There is
no such thing for a table cell that doesn't contain a form field.
Although it would be possible to use an application event handler for
the WindowSelectionChange event to change the background color of a
table cell, its behavior isn't very nice. See
http://www.eggheadcafe.com/software/...nd-to-red.aspx
for a discussion.

--
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.
 
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
Display width of text form field before being filled in. mandrews Microsoft Word Help 1 February 28th 08 02:37 PM
how do you underline a blank space that is to be filled in? EZ ed Microsoft Word Help 4 January 5th 08 04:45 AM
Shaded Form Field - shorter danka Microsoft Word Help 1 June 16th 06 04:45 PM
How to lock text field so form not changed when filled out? Melissa Microsoft Word Help 1 October 24th 05 08:38 PM
How do I put blank lines in a document to be filled in on the doc. tanjam Microsoft Word Help 0 March 28th 05 05:03 PM


All times are GMT +1. The time now is 03:05 AM.

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

About Us

"It's about Microsoft Word"