We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


I need to remove shading of a FORMTEXT Field on The Exit Macro...

MitchellVII asked
Medium Priority
Last Modified: 2012-06-21

My FormText Fields on my document are shaded GRAY (text only).  I want to write a bit of code that will remove that shading (to white) on the Exit Macro for the Field.  I can do this for Cells, but don't know how to do it when just the TEXT is shaded.

Thanks :)

Watch Question

Top Expert 2012

It's another sorry, I'm afraid Mitch. That shading applied to all formfields together, not one at a time.
It's the button next to the padlock on the Forms toolbar, or it's this property:


You may have misunderstood what I am looking for.

What I am doing rather than using the FORM FIELD shading tool is selecting each field and shading them individually as TEXT rather than as a FormField.  That's why I though I might be able to change it, by adjusting the TEXT shading.

Couldn't I do something like tell Word to look for any Text in the active cell and shade it white?  That may work.

I don't use the built in Form Field Shader as it is too dark.


P.S., how do you refer to an InlineShape Object when tryin to pass it to a Sub as an Object when you know the shapes name?  I know we were able to get there with a For Each...Next Loop, but I can't seem to get it to work stand-alone.
Top Expert 2012
OK. This should work as the exit macro

Sub ShadeFF()
    Dim rng As Range
    'Find the form field
    Set rng = Selection.Range
    Do Until rng.FormFields.Count > 0
        rng.MoveStart wdCharacter, -1
    'Hightlight the range
    Select Case Trim$(rng.FormFields(1).Result)
        Case ""
            rng.Font.Shading.BackgroundPatternColor = wdColorGray15
        Case Else
            rng.Font.Shading.BackgroundPatternColor = wdColorWhite
    End Select
End Sub

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Sorry I'm slow getting back to you on this one Graham, great solution :)

Quick question.  I may go a slightly different direction, but not sure how to do it.

Let's say I have a FormField in a cell and I want to change the Cell Backcolor light gray when I enter the Field and, back to white when I exit the field.  How would that work?

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.