Applying a different syle set to an existing doc

F

Franco

Hello,
I am up to a task that should not be too difficult, but I would really like
to know what is the proper way to approach it, with Word 2007.

I am given an existing doc (hundreds of pages) formatted with a set of
custom styles.
I am also given a template file, conteining a new different set of styles.

I need to apply the new set to the doc.

I am looking for the proper way to:

1) Import the new style set in my doc
2) Apply some kind of "mapping" between the old and the new styles (I hope I
don't have to do it selecting paraghraph by paragraph ...)

Thank you very much.

Franco
 
P

Peter T. Daniels

If the new set of styles has the same names as the old set of styles,
then you simply need to import the new styles into the existing
document.

If the new set of styles has all different names from the old set,
then you'll need to import the new styles and use Find/Replace to
replace each style individually (or make a macro containing each of
the pairs of old/new).

You import styles with the Organizer -- there are quite a few ways of
accessing it, for instance Ctrl-Alt-Shift-S (opens Styles & Formatting
panel), rightmost button at the bottom ("Manage Styles"); button at
lower left ("Import/Export"); in the right column near the bottom,
"Close File"; then "Open File" and choose the new template or navigate
to it and choose it; in the list of styles that appears above, select
all the ones that need to move into the old document (Ctrl-click to
select non-contiguous ones), and click "Copy" in the middle column.

To replace an old style with a new style, open Find/Replace (Ctrl-H),
then with the cursor in the Find what? box, More, Format, Styles;
choose the old style; put the cursor in the Replace with? box, and
enter the new style name; click Replace All. Repeat as needed for the
other styles.
 
G

Graham Mayor

Do the style *names* match in the old document and the new template? If so
attach the new template to the document (Developer Tab > Document Template >
Attach and check the Automatically Update Document Styles check box.)

If not you will need a macro to batch replace the old style with the new
one, but to achieve that, you will need a list of which old style names
should be replaced with which new ones e.g as follows. Put the old styles in
the first array each in quotes and separated by commas and their
replacements in the equivalent positions in the second array.
http://www.gmayor.com/installing_macro.htm

Ensure that you save the modified document with a new name so that you will
still have the old one to refer to.

Sub ReplaceStyleList()
Dim vFindStyle As Variant
Dim vReplaceStyle As Variant
Dim i As Long
vFindStyle = Array("Body Text", "Inside Address", "Date")
vReplaceStyle = Array("Normal", "Heading 2", "Body Text")
With Selection.Find
.ClearFormatting
.Text = ""
.Replacement.ClearFormatting
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindStyle) To UBound(vFindStyle)
.Style = vFindStyle(i)
.Replacement.Style = vReplaceStyle(i)
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

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

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