How do I stay in print layout when I select a field in a header? RRS feed


  • In that case, try something along the lines of the following VBA code:

    Sub Demo()
    Application.ScreenUpdating = False
    Dim Rng As Range, Sctn As Section, HdFt As HeaderFooter
    With ActiveDocument
      For Each Sctn In .Sections
        For Each HdFt In Sctn.Headers
          With HdFt
            If .LinkToPrevious = False Then
              With .Range
                With .Find
                  .Text = "xxx"
                  With .Replacement
                    .Text = ""
                  End With
                  .Forward = True
                  .Wrap = wdFindContinue
                  .Format = True
                End With
                If .Find.Found Then
                  Set Rng = .Duplicate
                  ActiveWindow.View.Type = wdPrintView
                  ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
                  Application.ScreenUpdating = True
                  Exit Sub
                End If
              End With
            End If
          End With
    End With
    Application.ScreenUpdating = True
    End Sub

    Paul Edstein
    [MS MVP - Word]

    • Marked as answer by DavidThi808 Friday, September 9, 2016 1:49 PM
    Thursday, September 8, 2016 1:47 AM

All replies