View Single Post
 
Old 01-05-2017, 02:04 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The following macro inserts prefixes every page with <pg> and ends it with </pg>
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument
  For i = .ComputeStatistics(wdStatisticPages) To 2 Step -1
    .GoTo(What:=wdGoToPage, Name:=i).InsertBefore "</pg><pg>"
  Next
  .Range.InsertBefore "<pg>"
  .Range.InsertAfter "</pg>"
End With
Application.ScreenUpdating = True
End Sub
Note that the code works backwards through the document, so that its own additions don't disturb the locations of the original page breaks.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote