Thread: [Solved] Detecting_paragraph
View Single Post
 
Old 11-27-2022, 05:10 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You could use the following function to count the number of lines in a range
Code:
Function NumLines(Rng As Range) As LongPtr
'Graham Mayor - http://www.gmayor.com
Const wdStatisticLines As LongPtr = 1
    NumLines = Rng.ComputeStatistics(wdStatisticLines)
lbl_Exit:
    Exit Function
End Function
Call it from your process e.g.
Code:
Sub macro1()
MsgBox NumLines(Selection.Paragraphs(1).Range)
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote