How can I determine the paragrah number of a selected paragraph

A

AndyE92

or notIf I wish to find a paragraph number from VB code, how can I do this?
Does it matter if the paragraph has a list number or outline number
associated with it or not?
 
D

Doug Robbins - Word MVP

Dim i As Long, prange As Range, srange As Range
Set srange = Selection.Range
With ActiveDocument
For i = 1 To .Paragraphs.Count
Set prange = .Paragraphs(i).Range
If srange.Start >= prange.Start And srange.End <= prange.End Then
MsgBox "The selection is in Paragraph " & i
Exit Sub
End If
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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