Macro to remove page numbers

Joined
Jul 13, 2012
Messages
1
Reaction score
0
Hi there. First I want to thank the contributors here - this forum is such an amazing resource.

I put together a macro to remove headers/footers based on the instructions here:

https://www.pcreview.co.uk/forums/print-word-document-without-header-and-footer-t3576237.html

and it worked like a charm. However, I now realize that I need the footers to show so that I can keep a watermark on all the pages. I still want a macro that removes all page numbering (from the entire document). Can anyone provide the appropriate language? Please let me know if the request is unclear. Thanks to all!
 
Joined
Jun 15, 2012
Messages
5
Reaction score
0
Sub DeletePageNumbers()

Dim objSect As Section
Dim objHF As HeaderFooter
Dim objPNum As PageNumber

For Each objSect In ActiveDocument.Sections

For Each objHF In objSect.Headers
For Each objPNum In objHF.PageNumbers
objPNum.Delete
Next
Next

For Each objHF In objSect.Footers
For Each objPNum In objHF.PageNumbers
objPNum.Delete
Next
Next

Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top