Mega Code Archive

 
Categories / VisualBasic Script / Word
 

Checking to See if a Header or Footer Exists

Sub footer()     Dim cSection As Section     With ActiveDocument         For Each cSection In .Sections             cHeader = cSection.Headers(wdHeaderFooterEvenPages)             If Not cSection.Headers(wdHeaderFooterEvenPages).Exists Then                 cSection.PageSetup.OddAndEvenPagesHeaderFooter = True                 cSection.Headers(wdHeaderFooterEvenPages).Range.Text _                     = "Section " & cSection.Index & " of " & .FullName                 cSection.Headers(wdHeaderFooterEvenPages).Range. _                     Style = "Even Footer"             End If         Next cSection     End With End Sub