last paragraph on current page

P

Peaceful Wisdom

How do I get the paragraph number for the last paragraph on the current page?
I'm using XPH and Word 2002.
 
H

Helmut Weber

Hi,

last complete paragraph on a page?
Given there is a complete paragraph at all?
 
N

Noline Wilson

I knew someone was going to ask that.
No. If the paragraph begins on the current page, I need to know it's
number.

message | Hi,
|
| last complete paragraph on a page?
| Given there is a complete paragraph at all?
|
| --
| Greetings from Bavaria, Germany
| Helmut Weber, MVP WordVBA
| "red.sys" & chr(64) & "t-online.de"
| Word 2002, Windows 2000
 
J

Jean-Guy Marcil

Peaceful Wisdom was telling us:
Peaceful Wisdom nous racontait que :
How do I get the paragraph number for the last paragraph on the
current page? I'm using XPH and Word 2002.

Dim MyPage As Range
Dim PartialDoc As Range
Dim LastParOnPage As Long

Set MyPage = ActiveDocument.Bookmarks("\Page").Range

Set PartialDoc = ActiveDocument.Range(0, MyPage.End)
LastParOnPage = PartialDoc.Paragraphs.Count

MsgBox "The last paragraph that starts on this page is number " _
& LastParOnPage & " in the doucment.", vbInformation, "Paragraph count"

But keep in mind that if there are spacer paragraphs (Lines with only a
paragraph mark : ¶) those are also included in the count.

For more on this, see
http://word.mvps.org/FAQs/MacrosVBA/GetIndexNoOfPara.htm

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
N

Noline Wilson

OK, This works, but I do have spacer lines, as well as, other lines.
Perhaps this will be helpful:

The only paragraphs that I need to count, are paragraphs that are a
numbered list. I have several numbered lists in the document, and
there are multiple numbered lists on each page. I also have the
document formatted for multiple columns on each page as well.

On the first page, the first numbered list is 1, the last numbered
list on that page is 31. On the second page, the first numbered list
is obviously 32. And the last numbered list on page two is 69.

What I need is a function that will return the number of the last
numbered list that begins on the current page: For example, 31 for
page one and 69 for page two.

Some paragraphs bleed over to the next page, and some do not.

Here is the function as it stands now:

Function LastParagraphOnPage() As Integer
Dim ThePage As Range
Dim PartialDoc As Range

ActiveWindow.View.Type = wdNormalView
Set ThePage = ActiveDocument.Bookmarks("\Page").Range
Set PartialDoc = ActiveDocument.Range(0, ThePage.End)
LastParagraphOnPage = PartialDoc.Paragraphs.Count
ActiveWindow.View.Type = wdPrintView
End Function

I do not use Word programming much at all, so all help will be greatly
appreciated.

Thanks.
 
H

Helmut Weber

High Noline,
The only paragraphs that I need to count,
are paragraphs that are a numbered list.

That's quite a different story.
I don't think you'll have 31 lists on one page,
but a automatically numbered list, and the last
number is 31, that is to say,
the listvalue of the last listparagraph on page one is 31.

Have a look at this one:

Dim rTmp As Range ' a temporary range
Dim lPrg As Long ' a counter
Set rTmp = Selection.Bookmarks("\page").Range
' the page where the insertion point is
lPrg = rTmp.ListParagraphs.Count
MsgBox rTmp.ListParagraphs(lPrg).Range.ListFormat.ListValue
 
N

Noline Wilson

OK, that's close, but not exactly right.

This gives me the value of the number, but what I need is the number
of which paragraph it is. Starting from page one, the last numbered
list paragraph on that page is 31, on page two, the last paragraph
number is 69. That is to say, that there are a total of 69 numbered
list paragraphs from the start of page one to the end of page two.

For example, in the entire document, there are (for discussion), a
total of 31,102 paragraphs that are numbered. The numbering is not
cumulative, each list begins with a list value of 1, and the ending
list value is different each time.

In the example, at the end of page two, I'm in my third numbered list,
and the list value is 13, but the total count of numbered list
paragraphs starting from page one is 69.

And this is what I need. Basically, I need to know the total count of
numbered list paragraphs there are starting at page one and including
all the numbered paragraphs on whichever page I'm on. Refer to this
table:

Page Starting Ending
1 1 31
2 32 69
3 70 105
4 106 149
5 150 ???

Thanks for the help, but as I mentioned before, I don't use Word
programming that much.
 
H

Helmut Weber

Hi Noline,

if I understand you right this time,
then take the example from Jean-Guy and change this line:

LastParOnPage = PartialDoc.Paragraphs.Count

to

LastParOnPage = PartialDoc.ListParagraphs.Count
 

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