Article ID: 181539
Article Last Modified on 6/17/2005
Sub InsertSectionTurnOffSameAsPrevious()
Dim hHeader As HeaderFooter
Dim iSection As Integer
' Insert Next Page section break.
Selection.InsertBreak Type:=wdSectionBreakNextPage
' Get current section number.
iSection = Selection.Information(wdActiveEndSectionNumber)
' For each Header type in the current section,
' turn off Same As Previous.
For Each hHeader In ActiveDocument.Sections(iSection).Headers
hHeader.LinkToPrevious = False
Next hHeader
End Sub
The following sample macro turns off Same As Previous for all headers and
footers in the document.
Sub TurnOffSameAsPrevious()
' Create variables.
Dim sSection As Section
Dim hfHeaderFooter As HeaderFooter
' Go to each section in the document.
For Each sSection In ActiveDocument.Sections
' Turn off "Same As Previous" in all Headers.
For Each hfHeaderFooter In sSection.Headers
hfHeaderFooter.LinkToPrevious = False
Next
' Turns off "Same As Previous" in all Footers.
For Each hfHeaderFooter In sSection.Footers
hfHeaderFooter.LinkToPrevious = False
Next
Next sSection
End Sub
173707 OFF97: How to Run Sample Code from Knowledge Base Articles
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: wordcon
Keywords: kbbug kbnofix kbmacro kbdtacode KB181539