Why field shading persists

C

cayce

Is there a way to have a Word 2007 .docx file not reveal field shading? The
files in questions start out as .docm and are later saved as .docx.

I know you can unlink field codes by selecting all and doing a Ctrl + shift
+ F9 but since it appears the VB code is gone in a .docx, I do not understand
why the field shading persists?

I am trying to give coworkers simple instruction on how to prepare a Word
2007 file before sending to a customer. The field shading gives a very
undesirable boilerplate appearance should the recipient have the field
shading option turned on to always. The field shading persists with the .dox
file, a surprise to me.

Has anyone ever run into this and have an easy solution?
 
J

Jay Freedman

cayce said:
Is there a way to have a Word 2007 .docx file not reveal field
shading? The files in questions start out as .docm and are later
saved as .docx.

I know you can unlink field codes by selecting all and doing a Ctrl +
shift + F9 but since it appears the VB code is gone in a .docx, I do
not understand why the field shading persists?

The presence or absence of VB code has absolutely nothing to do with whether
field shading is shown. That's a complete non sequitur.
I am trying to give coworkers simple instruction on how to prepare a
Word 2007 file before sending to a customer. The field shading gives
a very undesirable boilerplate appearance should the recipient have
the field shading option turned on to always. The field shading
persists with the .dox file, a surprise to me.

If the recipient has the field shading option set to "always", then
presumably they expect to see field shading. Why are you trying to override
their preference? Just because you don't like it?
Has anyone ever run into this and have an easy solution?

The only "solution" is an AutoOpen macro that turns off the field shading
option when your document is opened. If you have any consideration for the
recipient, the macro will store the option's value before turning it off,
and an AutoClose macro will restore that setting. This has many problems,
though, starting with the fact that by default Word doesn't allow unsigned
macros in untrusted locations to run at all. If you sign the macro code and
it runs, then you have the situation that fields won't be shaded in other
documents the user may have open at the same time as your document, so
you're still going against the user's preference.

My best advice is to leave it alone.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
C

cayce

thanks Jay for the comments. As for field shading not related to VB code,
this is new information for me. Thanks for educating me about this.

As for field shading on the other end, I think the boilerplate appearance of
all the fields used in the document can be viewed as impersonalization by the
customer. This is the undesirable side effect I was referring to.

thanks again for your comments.
 
J

Jay Freedman

I think I may have misunderstood your purpose in asking. I assumed that the
form was being sent to the customer to be filled out by them and returned to
you -- that's a common scenario.

Is it the case that your coworkers are filling the fields, not the
customers? When the document is sent to the customer, would you be satisfied
if the fields were turned into plain text and were not form fields any more?

If that's the case, then add this macro to the template and provide a
toolbar button to run it when the document is ready (won't need any further
field entries):

Sub FinishForm()
With ActiveDocument
If .ProtectionType <> wdNoProtection Then
.Unprotect
End If

.Fields.Unlink
End With
End Sub

After this runs, there won't be any field shading because there won't be any
fields.

Two things that may not be obvious:

(1) When you add macro code to a template in Word 2007, you must save it as
a macro-enabled template (.dotm instead of .dotx) or else the code will be
stripped out. All of your macro code should be in this template, not in the
"starting document" -- there should not be any .docm file in your process.
You should be using Office button > New to base new documents on the
template.

(2) When you create a new document based on a macro-enabled template, the
macro code stays in the template; the document can be saved as a .docx file.
 
C

cayce

Yes..it is my coworkers who fill in what the macro prompts for. I'd like to
avoid the customer, who ultimately receives these files, from seeing all this
"back office" stuff.

I'll experiment with what you sent. I trust it doesn't disable the TOC in
the process.

I am deeply ignorant about Visual Basic and am tasked with supporting others
here who use the macros. I, however, did not do any of the VB design we have.
I know enough to be dangerous;)

thanks for the additional coaching Jay.
 
J

Jay Freedman

The macro, as is, would unlink all the fields in the document, including the
TOC; that, too, would become plain text and wouldn't update any more. If you
don't unlink it, it will show field shading just like the form fields would.
That's why I said the macro should be used "when the document is ready" -- in
other words, just before being sent.

It would be easy to modify the macro in various ways:

- Unlink only the form fields, leaving any other fields (TOC, page numbers,
dates, etc.) intact.

- Unlink all fields except the TOC (or a short list of other field types).

To do this, I'd need to know what specific kinds of fields are in the document,
and which types you do and don't want to unlink.
 
C

cayce

This is great news! It sounds like unlinking form fields is what I seek. I
THINK that means those fields that get updated when coworkers run the custom
macros that are in the documents...right? Any other fields in the files can
stay intact (TOC, page nos., outline heading nos., and the like).

Thanks again Jay for your time spent to date.
 
J

Jay Freedman

The following modification of the macro will unlink only form fields:

Sub FinishForm()
Dim thisFF As Field
With ActiveDocument
If .ProtectionType <> wdNoProtection Then
.Unprotect
End If

For Each thisFF In .Fields
If (thisFF.Type = wdFieldFormTextInput) Or _
(thisFF.Type = wdFieldFormDropDown) Or _
(thisFF.Type = wdFieldFormCheckBox) Then
thisFF.Unlink
End If
Next
End With
End Sub

While I was writing this, I discovered something I didn't know about before
(something that happens with great regularity <g>): Using a bit of VBA, it's
possible to turn off the shading of form fields, while still leaving them as
fields, independent of the shading of other fields. This short macro will do
it:

Sub NoFormFieldShade()
ActiveDocument.FormFields.Shading = False
End Sub

You can apply this macro once to the template, and the formfields in all
documents based on the template will stay unshaded -- even if the Field
Shading option in the Options dialog is set to Always, and therefore the
other kinds of fields are shaded.

So now you have two possible solutions. Pick the one you like the best.
 
G

Graham Mayor

Hmmm. I also looked at this yesterday and came across a snag with this
method of unlinking in that check boxes do not appear to unlink. They remain
as check box fields, but in this case you have not re-locked the form so
they don't actually work. I experimented briefly with conditionally
replacing them with checked or unchecked boxes from (say) the Wingdings
font, but I ran out of time before packing up for the day :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jay Freedman

That occurred to me later, but I didn't get as far as testing it. I hope
that Cayce either doesn't have any check boxes or opts to use the
FormFields.Shading solution.
 
G

Gordon Bentley-Mix

:
While I was writing this, I discovered something I didn't know about before
(something that happens with great regularity <g>): Using a bit of VBA, it's
possible to turn off the shading of form fields, while still leaving them as
fields, independent of the shading of other fields. This short macro will do
it:

Sub NoFormFieldShade()
ActiveDocument.FormFields.Shading = False
End Sub
<snip>

AHA! This explains why the formfields in some of the form-based templates
I've "inherited" don't have any shading. Obviously some clever dick ran that
bit of code sometime. I was wondering what the story was. Thanks Jay!
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top