Highlight mergefields

J

Jules

I have set up a macro to highlight fields so that the printed document shows
the fields as shaded
This is the macro
On Error GoTo Nomorshading_Error
Dim oField As Field
For Each oField In ActiveDocument.Fields
oField.Result.HighlightColorIndex = wdGray25
Next oField
Release:
On Error Resume Next
Set oField = Nothing
Exit Sub
Nomorshading_Error:
Call MsgBox(Err.Description, vbCritical, "Nomoreshading() Catastrophic
Error")
GoTo Release
End Sub

This highlights fields such as fillins, asks etc. but does not highlight
mergefields that are brought into the document from a database package we
use. Any suggestions on getting the mergefields from the database to
highlight as well?

thanks
 
M

macropod

Hi Jules,

You don't need any vba for this - simply adding a Charformat switch to the
fields and formatting the fist character in each to match the desired output
format will do the job. Of course, you could use vba to add the switch and
formatting ...

Cheers
 
J

Jules

Thanks, but I don't want the shading to be in the field result permanently.
Sometimes when printing we want the fields results to be displayed as shaded
just for one printed copy and then the shading taken off. This is on a
variety of documents and so we just wanted a macro that would shade the
fields then the operator can print the doc and then run another macro to
unsahde the fields when they are finished. Hope you understand what I mean
by this
 
M

macropod

Hi Jules,

In that case, you could modify the fields, then close the document without
saving or, perhaps better still, permanently shade the first character of
each field, then use a macro to add/remove the Charformat switch as needed.
Without the Charformat switch, the shading won't come through in the output.

Cheers
 

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