Loop thru PageSetup.headers/footers

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
618
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
There are instances where the font I prefer cannot be printed so I need to update the font thruout a workbook. I know how to do so with the worksheet cells but I'm a bit stuck on the PageSetup headers & footers. I'm hoping there's a looping procedure I can use; I just have not been able to find the appropriate syntax.

My goal is that if the header/footer is not empty, to use whatever text is already present (sometimes it's static (creation date) and sometimes it's dynamic (Page &P of &N)) and only change the font (I know what the final font is but I don't always know the original font and sometimes there are multiple fonts). Additionally, there are formats that I would like to preserve (bold, color, size).

Thoughts? Thanks y'all.

Here's what the Macro Recorder provided.

VBA Code:
    Application.PrintCommunication = False
    With sht.PageSetup
        .LeftHeader = ""
        .CenterHeader = _
        "&""Consolas,Regular""&10File: &F || Sheet: &""Consolas,Bold""&KFF0000&A" & Chr(10) & "&""Consolas,Regular""&K000000Path: &K7030A0\\_Path\Path\Path\"
        .RightHeader = ""
        .LeftFooter = _
        "&""Consolas,Regular""Author: ______" & Chr(10) & "Created: 07/01/2021 || 10:18"
        .CenterFooter = "&""Consolas,Regular""Page &P of &N"
        .RightFooter = _
        "&""Consolas,Regular""Last Author: ______" & Chr(10) & "Last Modified: 07/01/2021 || 15:05"
    End With
    Application.PrintCommunication = True
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top