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

Posted on 2006-03-29
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 :)

Question by:MitchellVII
    LVL 76

    Expert Comment

    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:
    LVL 5

    Author Comment

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

    Accepted Solution

    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

    LVL 5

    Author Comment

    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

    A Knowledge Base That Stays Up-to-Date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
    When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
    This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
    This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now