Cross reference annoyances

M

Mike Starr

I'm using Word 2003 and there are two annoyances involving cross references.

1. When I've inserted a cross reference the cursor selection behavior has changed from previous versions. It used to be when I put the cursor in front of a cross reference and dragged across the cross reference, it would just grab the entire cross reference as if it was all a single character. That no longer happens and I'm guessing that I have some configuration setting incorrect to return that behavior. Can someone point me in the proper direction to restore this behavior?

2. When I insert cross references, I apply a character style (I've created one named "xref") to the cross reference. However, when the cross references are refreshed, the character style goes away. This issue is resolved by right-clicking the cross reference, choosing "Edit Field" and checking the "Preserve formatting during updates" checkbox on the "Field" dialog box displayed (adds MERGEFORMAT to the field). Ideally, I'd love to be able to insert a cross reference with the MERGEFORMAT already included and automatically apply my xref character style. However, I'd settle for just being able to insert a cross reference with the MERGEFORMAT already included. There's no setting in the Cross-reference dialog box to accomplish this. Any way I can do this?

Thanks

Mike
 
P

Peter T. Daniels

In 2007 there's an Option for selecting an entire field when you
select one character; you can probably find it 2003 also.

IIRC there's also an option for assigning a style to hyperlinks -- or,
it's conceivable that you can simply modify the included Hyperkink
style (mine is blue & underlined and I've never had a reason to change
it).
 
M

macropod

Hi Mike,

The MERGEFORMAT is added by default - you have to uncheck the 'preserve formatting' option to prevent its addition. In any event,
the MERGEFORMAT can be problematic if you want the cross-reference formatted in a particular way and the contents of the referenced
bookmark increase. What sometimes happens is that the extra text loses the formatting. To overcome that, you should use a Charformat
switch, as described in Word's Help file.
 
G

Graham Mayor

If you are inserting cross references to bookmarks, you can use the Insert>
Field option to insert the REF field and pick the bookmark from the list.
The following macro, which is a slight modification of a macro I use in my
own system, will open the field dialog with the ref field selected from
which you can select the relevant bookmark by name, and thus and will insert
a reference to the selected bookmark formatted with your xref style and the
Charformat switch applied..

Sub InsertRefField()
Dim oRng As Range
Dim i As Variant
Dim sSwitch As String
Dim strChoice As String
SendKeys "ref"
Dialogs(wdDialogInsertField).Show
On Error GoTo Finish
Selection.MoveLeft Unit:=wdCharacter, _
Count:=1, _
Extend:=wdExtend
Set oRng = Selection.Range
With oRng.Fields(1)
If InStr(1, .Code, _
"MERGEFORMAT") <> 0 Then
.Code.Text = Replace(.Code.Text, _
"MERGEFORMAT", _
"CHARFORMAT")
End If
If UCase(InStr(1, .Code, _
"CHARFORMAT")) = 0 Then
.Code.Text = .Code.Text _
& " \*CHARFORMAT"
End If
.Update
oRng.Style = "xref"
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Font.Reset
Finish:
End Sub
 
M

Mike Starr

ctually, that's not the case. MERGEFORMAT is *not* added by default. Here are screenshots that show the process I'm using:

http://www.writestarr.com/Cross-reference.gif
http://www.writestarr.com/ToggleFields.gif
http://www.writestarr.com/Field.gif
http://www.writestarr.com/ToggleFields2.gif

Step 1: Insert>>Cross reference; select heading, click *Insert*, click *Close*.
Step 2: Right-click>>Edit field...
Step 3: Check *Preserve formatting during updates* checkbox, click OK.
Step 4: Apply *xref* character style

I've seen the advice in this forum in the past to use the CHARFORMAT switch but have had no problems whatsoever with the MERGEFORMAT switch and see no reason to change. I have in the past created macros that updates a cross reference field with the MERGEFORMAT switch but if I can reduce the number of steps, I'd prefer to do that.

I already use the *Hyperlink* character style for web and email urls. I use my *xref* character style, which is formatted differently, to indicate cross references internal to the document.

Mike
 
M

macropod

Hi Mike,

You can have the "Preserve formatting during updates" option checked by default if you create the cross-reference via Insert|Field.
For the reasons previously given, though, doing so is not advised - the Charformat switch is far better at enforcing a particular
character format.
 
M

Mike Starr

I've learned how to manage cross references with MERGEFORMAT and like I said, don't see any need to stop using them.

However, taking your advice I investigated using Insert>>Field to insert a cross reference. The only item in the list that would allow me to do approximately the same as Insert>>Cross reference is Hyperlink. However, it applies the *Hyperlink* character style by default and I find that I'm unable to apply my *xref* style because it's inserted as a hyperlink rather than as a cross reference (REF).

Cross references are inserted as a REF but if I choose REF in the list of options, I'm only able to insert bookmarks.
 
M

macropod

Hi Mike,

Word applies a bookmark to anything that is cross-referenced. For headings etc, that bookmark is normally hidden - and doesn't exist
until the first time it's cross-referenced. If you insert a cross-reference to a heading in the normal manner, you can then access
the bookmark that Word creates for it. Sorry, but that's the best that can be done without resorting to a macro.

If that's too much trouble, it should be possible to write a macro that modifies the workings of the Insert|Cross-Reference dialogue
box, so that it both applies the MERGEFORMAT switch and your character style in one go. I suggest posting in
microsoft.public.word.vba.general and/or microsoft.public.word.vba.customization for any help you might need with that.
 
M

Mike Starr

Unfortunately, unless there's something under the hood that I'm not aware of, the Insert>>Cross Reference dialog box doesn't have the capability of applying the MERGEFORMAT switch; what I've done in the past is write a macro that toggles the field code, inserts the MERGEFORMAT switch and applies the character style. I was just hoping I could adjust a setting somewhere so that the MERGEFORMAT switch was applied by default. Thanks much for wading in and thinking about it.
 

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