Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change the background color of Form Field to white

Status
Not open for further replies.

barnard90

IS-IT--Management
Mar 6, 2005
73
US
Hi

I have a form field in MS Word 2003 . The default background color is grey color
How do I programmatically make to back ground color of the form field to white
The name of the form field is FField1.

There are other form fields in the Active document also. But I want only FField1 background color to change to white.
Please suggest the code.

thanks
 
1. FField1 is a poor name in that it has no meaning. You may as well name it YaddaYadda.

2. Set the highlight of its Range.

Code:
ActiveDocument.FormFields("Yadda") _
    .Range.HighlightColorIndex = wdWhite

Just to be clear, if you explicitly set the highlight of its Range, then toggling the Shading of formfields (which does indeed do all of them), will NOT change it. It will remain as whatever you have explicitly set the highlight. So in truth, it is not setting the background, it is setting the foreground...so to speak. Although it is not doing that either, really.

You can try playing with the Shading property of the range:
Code:
ActiveDocument.FormFields("YaddaYadda") _
   .Range.Shading.ForegroundPatternColor = _
        wdColorBrightGreen

Or ForegroundPatternColorIndex - which is different from ForegroundPatternColor.

However, you can get some unexpected results, so if it is simply to make that formfield white, with black text, I would recommend then using HighlightColorIndex.



faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top