Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    May 2006
    Location
    Currently in Europe
    Posts
    103
    Thanks
    7
    Thanked 0 Times in 0 Posts
    An ignorance that's tripped me up before, and now I want to get to grips with it. I've searched in the Word and VBA forums and find no answer.

    I'm building a macro to apply "space above" to certain paragraphs. I want to avoid doing this if the target paragraphs are at the top of a page.

    How do I determine if the beginning of a paragraph is on the first line of a page?
    Stylus

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You have to select the paragraph for this. You can then use code like this:

    Code:
    If Selection.Paragraphs(1).Range.Start = ActiveDocument.Bookmarks("\page").Range.Start Then
      ' paragraph starts at top of page
    Else
      ' paragraph does not start at top of page
    End If

  3. #3
    2 Star Lounger
    Join Date
    May 2006
    Location
    Currently in Europe
    Posts
    103
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Hans -

    Thanks!

    I couldn't be something obvious like page.top could it... Bookmarks indeed.

    Stylus
    Stylus

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    It's because a Word document doesn't really consist of pages - it's a long stream of content that is paginated on the fly when the document is viewed or printed. For convenience, Word provides a hidden bookmark named \page that represents the (first) page in the current selection.

    (There are other predefined hidden bookmarks, see WD2000: How to Use Built-in (Predefined) Bookmarks in Word; this article applies to later versions of Word too.)

  5. #5
    2 Star Lounger
    Join Date
    May 2006
    Location
    Currently in Europe
    Posts
    103
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Oooooooh, what an interesting set of tools! Thanks for that link.
    Stylus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •