last row on page

T

tbaam

I have a table that extends multiple pages in a word document. How do I find
the
last row on each page?

Thank You
 
H

Helmut Weber

Hi,

in principle like this:

With Selection.Bookmarks("\page").Range.Rows
MsgBox .Last.Range.Text
End With
 
T

tbaam

This helps...but now I have just one more question.

How do I go from page to page looking for the bookmark?
Thanks
 
H

Helmut Weber

Hi tbaam,
This helps...but now I have just one more question.

How do I go from page to page looking for the bookmark?

I thought so.

There was no mention of a bookmark, so far.

Sub Macro2()
Dim l As Long ' just a counter
Dim p As Long ' number of pages
ActiveDocument.Range(0, 0).Select
p = ActiveDocument.ComputeStatistics(wdStatisticPages)
For l = 1 To p
Selection.GoTo _
what:=wdGoToPage, _
which:=wdGoToAbsolute, _
Count:=l
Selection.Bookmarks("\page").Select
MsgBox Selection.Range.Rows.Last.Range.Text
Next
End Sub

Doing something with the text the messagebox displays,
as there are end-of-cell and end-of-row characters in it
would be another challenge, I guess.

HTH

One step after the other.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

tbaam

PERFECT!

Thanks

Helmut Weber said:
Hi tbaam,


I thought so.

There was no mention of a bookmark, so far.

Sub Macro2()
Dim l As Long ' just a counter
Dim p As Long ' number of pages
ActiveDocument.Range(0, 0).Select
p = ActiveDocument.ComputeStatistics(wdStatisticPages)
For l = 1 To p
Selection.GoTo _
what:=wdGoToPage, _
which:=wdGoToAbsolute, _
Count:=l
Selection.Bookmarks("\page").Select
MsgBox Selection.Range.Rows.Last.Range.Text
Next
End Sub

Doing something with the text the messagebox displays,
as there are end-of-cell and end-of-row characters in it
would be another challenge, I guess.

HTH

One step after the other.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top