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

对着背影说爱祢 提交于 2021-01-29 15:03:06

问题


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

回答1:


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"


来源:https://stackoverflow.com/questions/65657565/word-macro-to-change-footer-font-size-and-set-it-different-from-the-different-he

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!