none
Remove empty lines at the top of every page RRS feed

  • Question

  • Hi, I would like to perform the actions described below, in a Word document. Those two procedures must be performed for the same page, before moving on to the next page.

    Example:

    Go to page 1:

    Remove all empty lines at the top of page 1

    Search: ([!^13A-z]^13)(Nº)
    Replace: \1^13\2


    **

    Go to page 2:

    Remove all empty lines at the top of page 2

    Search: ([!^13A-z]^13)(Nº)
    Replace: \1^13\2


    **

    And so on to the last page.

    Thank you.
    Friday, July 19, 2013 7:26 PM

Answers

  • Here's the basic code to "walk" the pages of a Word document:

    Sub JumpToPages()
    '
    ' JumpToPages Macro
    '
    '
        Dim rngMove As word.Range
        Selection.HomeKey Unit:=wdStory
        Set rngMove = ActiveDocument.Characters.Last
        Debug.Print ActiveDocument.Bookmarks("\Page").Range.Information(wdActiveEndPageNumber)
        Do While Not Selection.Range.InRange(rngMove)
            Set rngMove = Selection.Range
            Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
            Debug.Print ActiveDocument.Bookmarks("\Page").Range.Information(wdActiveEndPageNumber)
        Loop
    End Sub


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, July 20, 2013 10:50 AM
    Moderator

All replies

  • Here's the basic code to "walk" the pages of a Word document:

    Sub JumpToPages()
    '
    ' JumpToPages Macro
    '
    '
        Dim rngMove As word.Range
        Selection.HomeKey Unit:=wdStory
        Set rngMove = ActiveDocument.Characters.Last
        Debug.Print ActiveDocument.Bookmarks("\Page").Range.Information(wdActiveEndPageNumber)
        Do While Not Selection.Range.InRange(rngMove)
            Set rngMove = Selection.Range
            Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
            Debug.Print ActiveDocument.Bookmarks("\Page").Range.Information(wdActiveEndPageNumber)
        Loop
    End Sub


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, July 20, 2013 10:50 AM
    Moderator
  • Ok, sorry I´m kinda newbie, how do I perform the actions I described in my initial post?

    • Edited by LCO Brz Monday, July 22, 2013 7:51 PM Change
    Monday, July 22, 2013 7:49 PM