Can you find a soft return with code

J

Jack B. Pollack

Is it possible to tell through code if a paragraph spans multiple lines
(has at least 1 soft line-wrap in it) under the current formatting?
 
M

macropod

Hi Jack,

The following function will count the number of lines in a
selection. All you need to do is to select the paragraph
and call it from the routine that needs the line count.

Cheers
PS: Remove NO.SPAM from the above before replying.

Public Function GetLineCount() As Long
Dim myrange As Range
ObtainLineCount = 0
Selection.SelectRow
Selection.Cells(1).Range.Select
Set myrange = Selection.Range
myrange.Select
Selection.Collapse wdCollapseStart
While Selection.InRange(myrange) = True 'while the cursor
is still in the current selection
GetLineCount = ObtainLineCount + 1 'add to the
line counter
Selection.MoveDown Unit:=wdLine, Count:=1
Wend
myrange.Select
Selection.Collapse wdCollapseStart
End Function
 
M

macropod

Or how about:

Cheers
Sub ParaLinesCount()
MsgBox "Line Count = " & Selection.Paragraphs
(1).Range.ComputeStatistics(wdStatisticLines)
End Sub
 

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