From: stephenc on
Thanks for sharing your knowledge. I've since spent some time playing around
with this in VBA, to really understand what Find|Replace can do with fields.
--
Stephenc


"Jay Freedman" wrote:

> For the Find What box, use the expression
>
> (STYLEREF*)Heading 1
>
> For the Replace With box, use
>
> \1Contents
>
> The (STYLEREF*) part of the search expression will match the word STYLEREF
> plus the space and quote mark, and that will be used as the value of the \1
> in the replacement expression.
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.
>
> stephenc wrote:
> > I've not used Replace to work with fields before. Just out of
> > interest, what is the construct for replacing the style name? For
> > example, if I wanted to change "Heading 1" to "Contents"?
> >
> >> The first step is to press Alt+F9 to display all the field codes in
> >> the document.
> >>
> >> The StyleRef field codes will probably look like
> >>
> >> { STYLEREF "Heading 1" \* MERGEFORMAT }
> >>
> >> although the keywords may be lower case or mixed case if some of the
> >> fields were created manually instead of using the Insert Field
> >> dialog.
> >>
> >> Open the Replace dialog, click the More button, and check the "Use
> >> wildcards" box. Put the following expression in the Find What box:
> >>
> >> (STYLEREF*Heading) 1
> >>
> >> and put this one in the Replace With box:
> >>
> >> \1 2
> >>
> >> Be careful to include the spaces in the expressions, or use
> >> copy/paste from this post. Make sure the Search dropdown is set to
> >> All, and click the Replace All button. This will search all the
> >> areas of the document, including headers and footers.
> >>
> >> If some of the field codes are lower case or mixed case, you'll need
> >> to repeat the replacement with the matching case in the Find What
> >> box; wildcard searches are always case-sensitive.
> >>
> >> --
> >> Regards,
> >> Jay Freedman
> >> Microsoft Word MVP FAQ: http://word.mvps.org
> >> Email cannot be acknowledged; please post all follow-ups to the
> >> newsgroup so all may benefit.
> >>
> >> stephenc wrote:
> >>> Hi everyone,
> >>> I need to change the properties of a lot of StyleRef fields, but am
> >>> not sure how to go about it. Where a StyleRef refers to "Heading 1"
> >>> I need it to refer to "Heading 2". The fields are mainly in headers
> >>> and footers, but could be anywhere in a document.
> >>
> >>
> >> .
>
>
> .
>