Bilal Hussain
Bilal Hussain

Reputation: 95

Word Macro to change footer font size and set it different from the different headers and the body in the documents?

I am trying to set a different font size for the footer in the document from the rest of the body. Moreover, how can I change font size of certain headings in the document without having knowledge of what the heading size might be? Any help would be appreciated! I am posting what I tried so far. Thank you!

Sub MyMacro()
 

    Selection.ParagraphFormat.LineSpacing = LinesToPoints(1.5)
    
    
    Set myRange =ActiveDocument.Sections.First.Headers(wdHeaderFooterPrimary).Range
    With myRange.Font
        .Name = "Palatino Linotype"
        .Size = 8
    End With

 
End Sub

Sub NewMacro()

 With ActiveDocument.Styles("Footer").Font
        .Name = "Palatino Linotype"
        .Size = 8.5
 End With

End Sub

Upvotes: 0

Views: 891

Answers (1)

macropod
macropod

Reputation: 13515

Your approach to document reformatting is poor practice and is prone to lead to document corruption. You should instead modify the Styles used in the document. For example:

With ActiveDocument.Styles("Normal").Font
  .Name = "Palatino Linotype"
  .Size = 11
End With

For your Header/Footer content, achieving the desired results there may necessitate the use of different Styles than you use in the document body.

Especially with the use of Styles, but even with your present approach, there is no need to Select anything or to switch views. For example:

ActiveDocument.Sections.First.Headers(wdHeaderFooterPrimary).Range.Style = "My Style"

Upvotes: 1

Related Questions