Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strip Headers from word docs

Status
Not open for further replies.

mudstuffin

Technical User
Sep 7, 2001
92
GB
Hello.

I use a sub to take out all the headers and footers of large documents (to reduce file sizes), but I want to be able to do run this on all word docs in a particular folder. Or maybe on all open documents. Can this be done with VBA....? This is what I use to strip the headers and footers from single documents....I trigger this from another document and the user chooses which open document to run it from based on its position in the 'windows' list.

Sub stripit()

Dim oSection As Section, oHeaderFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oHeaderFooter In oSection.Headers
oHeaderFooter.Range.Delete
Next
For Each oHeaderFooter In oSection.Footers
oHeaderFooter.Range.Delete
Next
Next

ActiveDocument.Save
ActiveDocument.Close

End Sub

Many Thanks,


mudstuffin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top