mudstuffin
Technical User
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
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