Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

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


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 :)

  • 2
  • 2
1 Solution
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:
MitchellVIIAuthor Commented:
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.
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

MitchellVIIAuthor Commented:
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?


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now