We help IT Professionals succeed at work.
Get Started

Macro to remove header and footer, print, then add them back and save

Last Modified: 2016-02-12
I currently have a few Microsoft Word (2007) macros for printing to different trays. We have a new document format being rolled out soon and I'd like to enhance one of the macros to include the process:


Remove Header AND Footer for page 1 ONLY (leaving other headers and footers intact)


Print the document (to the tray locations specified by the macro)


Add the page 1 Header AND Footer back as they were before the print


Save the document

The current macros are stored in a "macro-enabled document template" (.dotm) which is located in the %appdata%>Microsoft>Word>Startup directory which means the macros are available for ANY document that loads in MS Word.

There are three ways (so far) that I can work out how to do this be recording macros and editing my existing print macros to suit. These are:

Open a blank document > cut/paste the header into it > cut/paste the footer into it > print > copy/paste the header back > copy/paste the footer back > save > close the blank document without saving.
The problem with this is that (for document switching) the macro refers to the document by name. This won't work if they open a document with a different name out of the system.

Delete the header and footer > print> add the header and footer from "Building Blocks" (or QuickParts) > save.
The problem with this is that the building blocks or quick parts for the header and footer must exist already.

Open the MS Office Clipboard Collector > copy the Header and then the Footer to the clipboard > print > Paste the Footer then the Header back into the correct locations > clear the Clipboard Collector and close it > Save the document.
The problem with this is if the document has more than one page and the other pages have different headers... it will copy/paste the header and footer for the page currently being viewed when the macro button is pressed.

Is there a way to attach "building blocks" or "quick parts" to my custom .dotm template? This would be the quickest fix I can see.

If not, is there a way to automate the creation of these "building blocks" in the macro so that if they don't exist when the document is opened, they will be created and used. Will this create an issue for future use of the macro if the building blocks already exist from previous use of the macro?

Or is there any other way to achieve what I want?

Thanks in advance
Watch Question
Top Expert 2016
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE