I need to determine if a paragraph consists of multiple lines.
The only method that comes to mind is to check the vertical position
of the start of the paragraph with the vertical position of end of the
paragraph using ".Information(wdVerticalPositionRelativeToPage)".
Anyone have a better suggestion?
Thanks in Advance.

Signature
Tim Shaffer
Dave Lett - 17 Mar 2005 19:23 GMT
Hi Tim,
You might be able to use something like the following:
ActiveDocument.Paragraphs(1).Range.Select
With Dialogs(wdDialogToolsWordCount)
.Execute
MsgBox "This paragraph contains " & .Lines & " lines."
End With
HTH,
Dave
> I need to determine if a paragraph consists of multiple lines.
>
[quoted text clipped - 5 lines]
>
> Thanks in Advance.
Tim - 17 Mar 2005 20:09 GMT
This function appears to work
Sub TestMultipleLineParagraph()
MsgBox IsMultipleLineParagraph(Para:=Selection.Paragraphs(1))
End Sub
Function IsMultipleLineParagraph(Para As Paragraph) As Boolean
If Para.Range.Characters(1).Information(wdVerticalPositionRelativeToPage) = _
Para.Range.Characters(Para.Range.Characters.Count).Information(wdVerticalPositionRelativeToPage) Then
IsMultipleLineParagraph = False
Else
IsMultipleLineParagraph = True
End If
End Function
> I need to determine if a paragraph consists of multiple lines.
>
[quoted text clipped - 5 lines]
>
> Thanks in Advance.
Howard Kaikow - 17 Mar 2005 20:21 GMT
Does the following do the deed?
Public Sub WhichLineAmIIn()
' How do I determine if a paragraph consists of more than 1 line?
Dim blnEndOfDoc As Boolean
Dim lngEnd As Long
Dim lngStart As Long
Dim rngEndPara As Range
Dim rngStartPara As Range
Set rngStartPara = Selection.Paragraphs(1).Range
Set rngEndPara = rngStartPara.Duplicate
With rngStartPara
If .End = .Start Then
blnEndOfDoc = (.End = ActiveDocument.Content.End - 1)
Else
blnEndOfDoc = (.End = ActiveDocument.Content.End)
End If
.Collapse Direction:=wdCollapseStart
lngStart = .Information(wdFirstCharacterLineNumber)
End With
With rngEndPara
.Collapse Direction:=wdCollapseEnd
If Not blnEndOfDoc Then
.MoveEnd Unit:=wdCharacter, Count:=-1
End If
lngEnd = .Information(wdFirstCharacterLineNumber)
End With
Debug.Print "Paragraph consists of " & IIf(lngStart = lngEnd, "", "more
than ") & "1 line"
Select Case WordBasic.CmpBookmarks("\Line", "\Para")
Case 0, 10
Debug.Print "Insertion point is in last line of the paragraph"
Case 8
Debug.Print "Insertion point is in first line of the paragraph"
Case Else
Debug.Print "Insertion point is not in first or last line of the
paragraph"
End Select
Set rngEndPara = Nothing
Set rngStartPara = Nothing
End Sub

Signature
http://www.standards.com/; See Howard Kaikow's web site.
>
> I need to determine if a paragraph consists of multiple lines.
[quoted text clipped - 6 lines]
>
> Thanks in Advance.
Helmut Weber - 17 Mar 2005 21:01 GMT
Hi Tim,
still another one.
Public Function MultiLine(oPrg As Paragraph) As Boolean
On Error GoTo weiter:
If oPrg.Range.Bookmarks("\line").Range = oPrg.Range Then
MultiLine = True
Else
weiter:
MultiLine = False
End If
End Function
Sub test8946()
Dim oPrg As Paragraph
For Each oPrg In ActiveDocument.Range.Paragraphs
' oPrg.Range.Select ' for testing only
MsgBox MultiLine(oPrg)
Next
End Sub
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Tim - 18 Mar 2005 18:47 GMT
Using the Function MultiLine I get an error on the
Para.Range.Bookmarks("\Line").Range line when
it is processing a single line paragraph.
I don't understand why.
> Hi Tim,
>
[quoted text clipped - 24 lines]
> Word XP, Win 98
> http://word.mvps.org/
Helmut Weber - 18 Mar 2005 19:20 GMT
Hi Tim,
what error?
By the way, utilizing bookmarks("\line").range
might not have been a good idea after all,
as it fails if there are empty lines,
and it fails on the last paragraph in a doc,
and maybe in some other cases, too.
Sorry.
As in the song by Mike Batt:
[...]
it seemed to be a good idea at the time.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Tim - 18 Mar 2005 20:26 GMT
Helmut,
Thanks for the reply.
I will go back to the solution using
.Information(wdVerticalPositionRelativeToPage).
The initial testing looked good but it seemed to have
problems with Landscape pages.
Thanks Again,
Tim
> Hi Tim,
> what error?
[quoted text clipped - 16 lines]
> Word XP, Win 98
> http://word.mvps.org/