Word 2003 - Changing Cross-Reference Style

D

DeeW

I am using Word 2003 and have a document where the headings are in
uppercase. When inserting a cross-reference the headings appear the same. I
would like to have the crossreference to be in sentence case. I followed
Graham Mayor's instructions from 6/29/2007 and created a Macro to globally
make the changes. However, I have a subsection and it now appears
capitalized. For example, the reference appears as SECTION 2(b) and when I
run the macro, it displays as Section 2(B) instead of Section 2(b). Any text
inside the parathensis should be ignored.

How can I fix this? Mr. Mayor's original macro code is below. Thanks.

Sub AddFirstCapSwitch()
ActiveWindow.View.ShowFieldCodes = True
With Selection.Find
.ClearFormatting
.Text = "^d REF"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = False

Do While .Execute
With Selection
.MoveRight Unit:=wdCharacter, Count:=1
.MoveLeft Unit:=wdCharacter, Count:=1
.TypeText Text:="\*lower \*Firstcap "
.Fields.Update
End With

' prepare for next loop
Selection.Collapse wdCollapseEnd
Loop
End With
ActiveWindow.View.ShowFieldCodes = False
End Sub
 
S

Suzanne S. Barnhill

Instead of typing the headings in uppercase, format the style as All Caps,
then type them in caps & lowercase.
 
G

Graham Mayor

I have tested the macro on your e-mail message entry and it works as
intended. I cannot recreate the problem you raise. Can you toggle the field
codes (ALT+F9) and see what is in the field?

Before running the macro it should be { REF Sec1 }

After running the macro it should be { Ref Sec1 \*lower \*Firstcap }
where Sec1 is the name of your bookmark.

Subsequent re-running the macro will re-add \*lower \*Firstcap to the field
thus

{ Ref Sec1 \*lower \*Firstcap \*lower \*Firstcap }

You can overcome that by adding the line .MatchCase as below

With Selection.Find
.ClearFormatting
.Text = "^d REF"
.Forward = True
.Wrap = wdFindStop
.MatchCase = True
.Format = False
.MatchWildcards = False

but then the macro will only work if REF is in upper case i.e. as inserted
by Insert Field
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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