If a cross reference (or any other field), is included in conditional content then you need to ensure the field code includes the MERGEFORMAT switch. Without the MERGEFORMAT switch the field will not be hidden when the conditional content is hidden.
Here is an example of a conditionalized field that is missing the MERGEFORMAT switch:
This field will still be visible when this conditional content is hidden because the MERGEFORMAT switch has been omitted.
Here is an example of the same conditionalized field with the MERGEFORMAT switch:
This field will be hidden when this conditional content is hidden because the MERGEFORMAT switch has been included.
Typically, Microsoft® Word automatically includes the MERGEFORMAT switch when fields are created. However, sometimes it omits the MERGEFORMAT when a REF field is created.
You can ensure the MERGEFORMAT switch is included in a field by checking the Preserve formatting during updates option in the Fields dialog box or by using ALT + F9 to toggle the display of field codes and manually adding the MERGEFORMAT switch to the appropriate fields.
How can I find cross reference fields that are missing the MERGEFORMAT switch
You can use the VBA macro below to scan your document for cross reference fields that are missing the MERGEFORMAT switch.
If this macro finds any cross reference fields missing this switch, then a new document will be opened that contains the page and line number of the offending cross reference fields.
Sub ReferenceFieldsMissingMergeFormat() Dim field As Field Dim code As String Dim result As String ' ///////////////////////////////////////// ' // Get REF fields missing MERGEFORMAT. // ' ///////////////////////////////////////// For Each field In ActiveDocument.Fields If field.Type = wdFieldRef Then code = LCase(field.Code.Text) If Not InStr(code, "mergeformat") Then result = result & "Page " & field.Code.Information(wdActiveEndPageNumber) & ", " result = result & "Line " & field.Code.Information(wdFirstCharacterLineNumber) & ": " result = result & field.Code.Text & vbVerticalTab End If End If Next field If result = "" Then MsgBox "There are no cross reference fields missing the MERGEFORMAT switch in this document." Exit Sub End If ' /////////////////////////////////////////// ' // Open new document and output results. // ' /////////////////////////////////////////// Dim document As Document Set document = Documents.Add document.Content.Text = "Cross reference fields missing the MERGEFORMAT switch" & vbCr & result End Sub
To Create this Macro in Microsoft Word
- Select the Developer tab.
- Select Macros.
- Type ReferenceFieldsMissingMergeFormat in the Macro name field.
- Click Create.
- Copy the contents of the macro code above.
- Paste it in between the Sub and End Sub lines.
- Click Save and Close.
To Execute this Macro Reopen Microsoft Word
- Select the Developer tab.
- Select Macros.
- Select the macro named ReferenceFieldsMissingMergeFormat.
- Click Run.
Great Macro - Thank You!!
It did "reveal" where the X-Ref did not contain \* MERGEFORMAT. However, having to manually change these is painful - when you have 20+; and:
Great Macro - Thank You!!
It did "reveal" where the X-Ref did not contain \* MERGEFORMAT. However, having to manually change these is painful - when you have 20+; and:
Great Macro - Thank You!!
It did "reveal" where the X-Ref did not contain \* MERGEFORMAT. However, having to manually change these is painful - when you have 20+; and:
Great Macro - Thank You!!
It did "reveal" where the X-Ref did not contain \* MERGEFORMAT. However, having to manually change these is painful - when you have 20+; and: