![]() |
|
#1
|
|||
|
|||
|
Greeting, I am wondering if paragraphs containing more than 1 line can be detected in word by using something like Code:
If Selection.paragraphs(1).range.count <> then
'If true then formats in one way else formats in another way.
End If
|
|
#2
|
||||
|
||||
|
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
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 |
|
#3
|
|||
|
|||
|
Thanks gmayor, It works like charm.
|
|
#4
|
||||
|
||||
|
Do be aware that approach returns 0 regardless of the line count when the paragraph is in a table cell.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|