![]() |
|
#2
|
||||
|
||||
|
Do you mean LINE or PARAGRAPH? It is highly likely that the last character on any given page is either a space or a paragraph mark although the last character you can see might be a ")"
This code does what you asked for (but perhaps not what you meant). I've dealt with a trailing space but not with a trailing paragraph mark. Code:
Sub LastLiner()
Dim aRng As Range, rngPage As Range, rngLine As Range, sText As String
Set rngPage = ActiveDocument.Bookmarks("\Page").Range
Do While rngPage.End + 1 < ActiveDocument.Range.End
rngPage.MoveEnd Unit:=wdCharacter, Count:=-1
rngPage.Collapse Direction:=wdCollapseEnd
rngPage.Select
Set rngLine = ActiveDocument.Bookmarks("\Line").Range
rngLine.Select
sText = Trim(rngLine.Text)
If sText Like "BY*" Or sText Like "EXAMINATION*" Or sText Like "*)" Then
Exit Do
Else
Selection.Collapse Direction:=wdCollapseEnd 'moves selection to top of next page
Set rngPage = ActiveDocument.Bookmarks("\Page").Range
End If
Loop
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to bold and center the first line of each page.
|
MDom | Word VBA | 4 | 02-21-2023 09:43 PM |
| 1st line of 4-line poem centrally aligned; how to get lines 2-4 to start at same location on page | Swarup | Word | 6 | 09-16-2022 11:07 AM |
| Section and Line Break leaving line on previous page | Stonehands99 | Word | 5 | 08-13-2019 08:59 PM |
Page no's in Footer: p. "9" is one line higher than all other page no's: How to bring it down 1 line
|
Swarup | Word | 24 | 12-30-2018 05:11 PM |
macro to add brackets to each line and add single quotes to each word in the line
|
bracketandquotes | Word VBA | 17 | 02-16-2015 03:51 PM |