Share via

How to change font size in footer VBA Word 2016

Anonymous
2020-04-28T16:57:21+00:00

Hi - I'm using some code (that helpfully was found in this community!!!!  Thanks Graham!) to insert a footer - I can't figure out how to make the font size change to 9 (just for the footer).

    Dim n As String

    Dim rG As Range

    Dim iRM As Long

    n = "File Number " & FNumberTextBox.Text

 With ActiveDocument.Sections(1)

     With .PageSetup

     iRM = .PageWidth - .RightMargin - .LeftMargin

     .DifferentFirstPageHeaderFooter = False

     End With

     Set rG = .Footers(wdHeaderFooterPrimary).Range

     rG.Text = "Page "

     rG.Collapse wdCollapseEnd

     ActiveDocument.Fields.Add rG, wdFieldPage, , False

     rG.Start = .Footers(wdHeaderFooterPrimary).Range.End

     rG.Text = " of "

     rG.Collapse wdCollapseEnd

     ActiveDocument.Fields.Add rG, wdFieldNumPages, , False

     rG.Start = .Footers(wdHeaderFooterPrimary).Range.End

     With rG.Paragraphs(1).TabStops

         .ClearAll

         .Add Position:=iRM, Alignment:=wdAlignTabRight

     End With

     rG.Text = vbTab & n

     .Footers(wdHeaderFooterPrimary).Range.Fields.Update

 End With

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Jay Freedman 207.7K Reputation points Volunteer Moderator
2020-04-28T17:22:34+00:00

After the line that starts with n = , insert this line:

ActiveDocument.Styles("Footer").Font.Size = 9

That will affect all footers in the document.

Was this answer helpful?

4 people found this answer helpful.
0 comments No comments

Answer accepted by question author

Jay Freedman 207.7K Reputation points Volunteer Moderator
2020-04-29T01:03:12+00:00

Also, the line of code I gave does modify the Footer style, although only in the current document. It would be possible, but not advisable, to have the macro also modify the Footer style of the document's template (and of Normal.dotm, if that isn't what the document is based on).

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Suzanne S Barnhill 278.1K Reputation points MVP Volunteer Moderator
    2020-04-28T20:13:19+00:00

    The style for footers is Footer. Footnote Text is for the text in footnotes.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2020-04-28T18:37:47+00:00

    Although you can do it in the macro, you might also want to consider doing it in the Footer style. That way all of the footers will be consistent in styling.  I'm not sure which specific style you have to update, I suspect it is Footnote Text.

    .

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2020-04-28T18:03:30+00:00

    After the line that starts with n = , insert this line:

    ActiveDocument.Styles("Footer").Font.Size = 9

    That will affect all footers in the document. 

    Thankyou - worked perfectly (you already knew that LOL)

    James

    Was this answer helpful?

    0 comments No comments