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

Answers

  • 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
                  .ClearFormatting
                  .Text = "xxx"
                  With .Replacement
                    .ClearFormatting
                    .Text = ""
                  End With
                  .Forward = True
                  .Wrap = wdFindContinue
                  .Format = True
                  .Execute
                End With
                If .Find.Found Then
                  Set Rng = .Duplicate
                  ActiveWindow.View.Type = wdPrintView
                  ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
                  Rng.Select
                  Application.ScreenUpdating = True
                  Exit Sub
                End If
              End With
            End If
          End With
        Next
      Next
    End With
    Application.ScreenUpdating = True
    End Sub


    Cheers
    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