Mega Code Archive

 
Categories / VisualBasic Script / Word
 

Adding Page Numbers to One or More Sections of a Document

Sub AddPageNumbersToAllHeadersAndSections()     Dim cHeader As HeaderFooter, cSection As Section     With Documents("YourDoc.doc")         For Each cSection In .Sections             For Each cHeader In cSection.Headers                 cSection.Headers(wdHeaderFooterPrimary).PageNumbers _                     .Add.PageNumberAlignment:= _                     wdAlignPageNumberRight, FirstPage:=True             Next cHeader         Next cSection     End With End Sub