A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

form - field shaded when blank, unshaded when filled in



 
 
Thread Tools Display Modes
  #1  
Old January 27th, 2010, 12:04 AM posted to microsoft.public.word.tables
Aliza Berger-Cooper[_2_]
external usenet poster
 
Posts: 4
Default form - field shaded when blank, unshaded when filled in

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
  #2  
Old January 27th, 2010, 03:10 AM posted to microsoft.public.word.tables
Jay Freedman
external usenet poster
 
Posts: 9,488
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.
  #3  
Old January 27th, 2010, 08:36 AM posted to microsoft.public.word.tables
Aliza Berger-Cooper[_2_]
external usenet poster
 
Posts: 4
Default All Groups Ask New Question Developer Outlook AddIns Excel ExcelCharting Excel Crashes GPFs Excel Miscellaneous Excel New Users ExcelProgramming Excel Setup Excel Worksheet Groove MAC Office MAC Office EntourageMAC Office Word Office Communicator Off

Jay,

Thanks so much for your helpful answer.

I have a followup question.

I want the user to be able to print the form (partially completed) with the blank fields shaded and the filled fields unshaded (accomplished as per your instructions).
The Microsoft site says this:

To add shading to a printed form, select the form field you want to emphasize, and then click Borders and Shading (Format menu). On the Shading tab, select the shading options you want.

Will this work in conjunction with your advice?

TIA again.

Aliza in Jerusalem



Jay Freedman wrote:

For text form fields, you can put this macro in the form template(change the
26-Jan-10

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 does not 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 is not 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.

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
Book Review: Silverlight 3 Programmer's Reference [Wrox]
http://www.eggheadcafe.com/tutorials...lverlight.aspx
  #4  
Old January 27th, 2010, 08:41 AM posted to microsoft.public.word.tables
Aliza Berger-Cooper[_2_]
external usenet poster
 
Posts: 4
Default All Groups Ask New Question Developer Outlook AddIns Excel ExcelCharting Excel Crashes GPFs Excel Miscellaneous Excel New Users ExcelProgramming Excel Setup Excel Worksheet Groove MAC Office MAC Office EntourageMAC Office Word Office Communicator Off

I see that the Microsoft advice I quoted might not have come through. It was:

To add shading to a printed form, select the form field you want to emphasize, and then click Borders and Shading (Format menu). On the Shading tab, select the shading options you want.

To top this off, is it possible to pre-fill a form field with text that will disappear when the person types in the field? E.g the text field will be pre-filled with "Name" until the person types in their name.

And how will this work in conjunction with the shading options?

-Aliza in Jerusalem



Aliza Berger-Cooper wrote:

All Groups Ask New Question Developer Outlook AddIns Excel Excel Charting Excel Crashes GPFs Excel Miscellaneous Excel New Users Excel Programming Excel Setup Excel Worksheet Groove MAC Office MAC Off
27-Jan-10

Jay,

Thanks so much for your helpful answer.

I have a followup question.

I want the user to be able to print the form (partially completed) with the blank fields shaded and the filled fields unshaded (accomplished as per your instructions).
The Microsoft site says this:

To add shading to a printed form, select the form field you want to emphasize, and then click Borders and Shading (Format menu). On the Shading tab, select the shading options you want.

Will this work in conjunction with your advice?

TIA again.

Aliza in Jerusalem

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
The FAST TRACK to ASP.NET
http://www.eggheadcafe.com/tutorials...to-aspnet.aspx
  #5  
Old January 27th, 2010, 08:46 AM posted to microsoft.public.word.tables
Aliza Berger-Cooper[_2_]
external usenet poster
 
Posts: 4
Default form - field shaded blank, unshaded when filled in, p.p. s.

I see that when I copy and paste from Microsoft, it doesn't come through for some reason. I will type it out:

To add shading to a printed form, select the form field you want to emphasize and then click Borders and Shading (Format Menu). On the Shading tab, select the options you want.

-Aliza in Jerusalem



Aliza Berger-Cooper wrote:

All Groups Ask New Question Developer Outlook AddIns Excel Excel Charting Excel Crashes GPFs Excel Miscellaneous Excel New Users Excel Programming Excel Setup Excel Worksheet Groove MAC Office MAC Off
27-Jan-10

I see that the Microsoft advice I quoted might not have come through. It was:

To add shading to a printed form, select the form field you want to emphasize, and then click Borders and Shading (Format menu). On the Shading tab, select the shading options you want.

To top this off, is it possible to pre-fill a form field with text that will disappear when the person types in the field? E.g the text field will be pre-filled with "Name" until the person types in their name.

And how will this work in conjunction with the shading options?

-Aliza in Jerusalem

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
SQL Server - Detach / Attach / Full Text Catalog
http://www.eggheadcafe.com/tutorials...tach--att.aspx
  #6  
Old January 27th, 2010, 05:09 PM posted to microsoft.public.word.tables
Jay Freedman
external usenet poster
 
Posts: 9,488
Default All Groups Ask New Question Developer Outlook AddIns Excel Excel Charting Excel Crashes GPFs Excel Miscellaneous Excel New Users Excel Programming Excel Setup Excel Worksheet Groove MAC Office MAC Office Entourage MAC Office Word Office Communica

The shading applied by the macro is exactly the same as the shading you
could apply from the Borders and Shading dialog. It will print. There is no
need to do anything else.

--
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.

Aliza Berger-Cooper wrote:
Jay,

Thanks so much for your helpful answer.

I have a followup question.

I want the user to be able to print the form (partially completed)
with the blank fields shaded and the filled fields unshaded
(accomplished as per your instructions).
The Microsoft site says this:

To add shading to a printed form, select the form field you want to
emphasize, and then click Borders and Shading (Format menu). On the
Shading tab, select the shading options you want.

Will this work in conjunction with your advice?

TIA again.

Aliza in Jerusalem



Jay Freedman wrote:

For text form fields, you can put this macro in the form
template(change the 26-Jan-10

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 does not 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 is not very nice. See
http://www.eggheadcafe.com/software/...nd-to-red.aspx
for a discussion.



  #7  
Old January 27th, 2010, 05:15 PM posted to microsoft.public.word.tables
Jay Freedman
external usenet poster
 
Posts: 9,488
Default All Groups Ask New Question Developer Outlook AddIns Excel Excel Charting Excel Crashes GPFs Excel Miscellaneous Excel New Users Excel Programming Excel Setup Excel Worksheet Groove MAC Office MAC Office Entourage MAC Office Word Office Communica

The material you quoted did appear in your previous message, although it
might not have shown on the web page you were using. As I answered there,
the macro applies the same shading as the Borders and Shading dialog, and
there is no need to use the dialog.

To answer your second question, while you're creating the form and the
document is unprotected, double-click the form field or click the Properties
button on the Forms toolbar to open the field's Properties dialog. At the
top right of the dialog, enter your text in the Default Text box.

--
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.

Aliza Berger-Cooper wrote:
I see that the Microsoft advice I quoted might not have come through.
It was:

To add shading to a printed form, select the form field you want to
emphasize, and then click Borders and Shading (Format menu). On the
Shading tab, select the shading options you want.

To top this off, is it possible to pre-fill a form field with text
that will disappear when the person types in the field? E.g the text
field will be pre-filled with "Name" until the person types in their
name.

And how will this work in conjunction with the shading options?

-Aliza in Jerusalem



Aliza Berger-Cooper wrote:

All Groups Ask New Question Developer Outlook AddIns Excel Excel
Charting Excel Crashes GPFs Excel Miscellaneous Excel New Users Excel
Programming Excel Setup Excel Worksheet Groove MAC Office MAC Off
27-Jan-10

Jay,

Thanks so much for your helpful answer.

I have a followup question.

I want the user to be able to print the form (partially completed)
with the blank fields shaded and the filled fields unshaded
(accomplished as per your instructions).
The Microsoft site says this:

To add shading to a printed form, select the form field you want to
emphasize, and then click Borders and Shading (Format menu). On the
Shading tab, select the shading options you want.

Will this work in conjunction with your advice?

TIA again.

Aliza in Jerusalem

Previous Posts In This Thread:


Submitted via EggHeadCafe - Software Developer Portal of Choice
The FAST TRACK to ASP.NET
http://www.eggheadcafe.com/tutorials...to-aspnet.aspx



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.