Sam,
"Every line in word is a paragraph" That is not true. A paragraph can have one line or hundreds. What is true is every press of the Enter key creates a new paragraph. If you press it twice and then start typing then you created two (one for space and one for your text).
As Andrew said, checking every paragraph to see if it is empty would just add to the time is take to process and return the user location.
That is one of the drawbacks of the GetLocation method. It is evaluating every page, every rectangle, every line up to the the users selection point. That is a laborious process. Nothing for a short letter or two or three page document but a big drag in a big document. I have a document that is 1510 pages long. I have a very robust PC and it still look close to a minute to report the cursor look on page 1500.
However, if you wanted to exclude empty paragraphs, and empty text rectangle in the document structure has a range length of 1. So you could modify to:
Note: This code has not be tested with documents containing tables or other graphical elements.
Code:
Sub GetLocation()
Dim oPage As Page
Dim oRect As Rectangle
Dim oLine As Line
Dim lngPage As Long, lngRect As Long, lngLine As Long
Dim lngParCount As Long, lngLineCount As Long, lngPLCount As Long
Dim bResolved As Boolean
bResolved = False
For lngPage = 1 To ActiveDocument.ActiveWindow.Panes(1).Pages.Count
Set oPage = ActiveDocument.ActiveWindow.Panes(1).Pages(lngPage)
For lngRect = 1 To oPage.Rectangles.Count
Set oRect = oPage.Rectangles(lngRect)
On Error GoTo Err_Handler
If oRect.Range.StoryType = wdMainTextStory Then
If oRect.RectangleType = wdTextRectangle Then
If Len(oRect.Range) > 1 Then 'An empty TextRectangle as a range lenght = 1
lngParCount = lngParCount + 1
If Selection.InRange(oRect.Range) Then
For lngLine = 1 To oRect.Lines.Count
Set oLine = oRect.Lines(lngLine)
lngPLCount = lngPLCount + 1
If Selection.InRange(oLine.Range) Then
lngLineCount = lngLineCount + lngPLCount
bResolved = True
Exit For
End If
Next lngLine
Else
lngLineCount = lngLineCount + oRect.Lines.Count
End If
End If
If bResolved Then Exit For
End If
End If
NextRect:
Next lngRect
If bResolved Then Exit For
Next lngPage
MsgBox "The cursor is in Dococument paragraph number: " & lngParCount & vbCr _
& "Document line number: " & lngLineCount & vbCr _
& "Paragraph line number: " & lngPLCount
lbl_Exit:
Exit Sub
Err_Handler:
Resume NextRect
End Sub
"So any type of indication thru VBA or any VBA syntax to know what style has been used for inter-paragraph and what spacing has been incorported.
Rather than Selecting document/Paragraph and checking for Space Size after each paragraph"
You could do a find and replace looking for ^13^13. Any found would indicate the user has used paragraphs for spacing.