Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What line on page (Word 2000)

    I have looked in the Lounge, MS support KB, and

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: What line on page (Word 2000)

    The Information property of the Range object includes:
    wdFirstCharacterLineNumber Returns the line number of the first character in the selection. If the Pagination property is False or the Draft property is True, returns
    Regards
    John



  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: What line on page (Word 2000)

    Just catching up on unread postings. The following aspect of the Information property can be used:

    Selection.Information(wdVerticalPositionRelativeTo Page)

    Hope this helps.

    Fred

  4. #4
    New Lounger
    Join Date
    Oct 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What line on page (Word 2000)

    Thanks Guys,

    At first I thought this was the answer, but when I ran the code the program seems to be ahead of the document.
    Even though I am actually at line three or some other low line number the program seems to think I am well beyond the test range, and consequently my test forces a page break.

    Again I am at a standstill. What seem to be the simplest problems turn out to be the biggest problems. Here is what I have tried, in both instances the system thinks it is well beyond my test point.
    ================================================== ======
    If Selection.Range.Information(wdFirstCharacterLineNu mber) > 30 Then
    Selection.InsertBreak Type:=wdPageBreak
    End If
    ================================================== ======
    If Selection.Information(wdVerticalPositionRelativeTo Page) > 540 Then
    Selection.InsertBreak Type:=wdPageBreak
    End If
    ================================================== ======
    Thanks again for any help,
    J. Bergk

  5. #5
    New Lounger
    Join Date
    Oct 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: What line on page (Word 2000)

    One other quick thing I forgot in my previous message. Both instances of the test work great when I'm in Breakpoint Mode. But when code is running is where the problems arise.

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: What line on page (Word 2000)

    Hi J,

    One possible workaround:
    Paste each block into a new row of a single-column table formatted not to allow cells to break across pages. That will force any new cell that is too long to fit on the current page to start on a new one - unless it's already the only cell on that page.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: What line on page (Word 2000)

    > The problem I have is first, I need to be able to determine where I am on a page in terms of what line I am on,
    > because I may want to insert a page break if there is not sufficient space at the bottom of the page.

    If you think about Word as a word processor rather than as a report generator, more options come to light. When you want paragraphs to stay together, use the option "Keep with Next." Depending on how you are inserting the text, this could be roughly as follows:

    <pre>Sub PasteAway()
    'Set up Sticky style
    With ActiveDocument
    .Styles.Add "Sticky"
    With .Styles("Sticky")
    .BaseStyle = wdStyleNormal
    .ParagraphFormat.KeepWithNext = True
    End With
    End With

    'Loop through report data
    ' Stand-alone paragraphs
    TypeIt "Some data", False
    TypeIt "Some more data", False
    ' Type in paragraphs to be kept together
    TypeIt "Even more data", True
    TypeIt "Yet more data", True
    ' Type in last paragraph of the group
    TypeIt "Total", False
    End Sub

    Sub TypeIt(strText As String, blnKeepWithNext As Boolean)
    If blnKeepWithNext Then
    With Selection
    If .Style <> "Sticky" Then
    .Style = "Sticky"
    End If
    .TypeText strText & vbCrLf
    End With
    Else
    With Selection
    If .Style = "Sticky" Then
    .Style = wdStyleNormal
    End If
    .TypeText strText & vbCrLf
    End With
    End If
    End Sub</pre>

    With Range.InsertAfter, I the code would be different; off the top of my head, I don't know what it would be.

Posting Permissions

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