memyself
memyself

Reputation: 12628

how to re-apply / update style / font to all paragraphs but some?

I have a very long Word document and the fonts of individual paragraphs are quite diverse and many (text sans serif, subtitles and titles serifs). The only style that is consistently and correctly applied are captions and headers 1 to 4.

Is there a way to apply a common font to ALL paragraphs BUT the captions and headers without losing bold and italic formatting of these paragraphs? I tried to re-apply styles as described here http://www.elharo.com/blog/word/2005/12/28/word-tip-1-reapplying-styles/ but this will only work for paragraphs that don't have any italic or bold formatting (or http links)

The way I see it currently, the only way to get consistent fonts and styles for normal paragraphs is to a) remove all formatting by applying a style to each paragraph individually and then go through each paragraph and manually re-apply bold / italic / http formatting to those parts that have now been overwritten.

Is there an alternative way of doing this? There must be, right? VBA? something else?

EDIT:

Is something like the following possible (pseudo code):

for i in all_paragraphs()
    if i.style not in [header1, header2, header3, caption, ...]
        i.font = my_new_font

that way any markup should stay preserved.

Upvotes: 0

Views: 2788

Answers (1)

Drew Gaynor
Drew Gaynor

Reputation: 8472

This task can be accomplished fairly easily with VBA, as you said:

    Sub changeStyles()
        Dim p As Paragraph

        For Each p In ActiveDocument.Paragraphs
            If p.Range.Style <> "Caption" _
            And p.Range.Style <> "Heading 1" _
            And p.Range.Style <> "Heading 2" _
            And p.Range.Style <> "Heading 3" _
            And p.Range.Style <> "Heading 4" _
            Then
                p.Range.Font.Name = "Arial"
            End If
        Next
    End Sub

This code will apply whatever styles you'd like to every Paragraph object in the document that doesn't have one of the styles you mentioned. p.Range.Font has many members that you may find useful, such as Bold and Italic, if you have have a need to change those properties as well.

Upvotes: 2

Related Questions