Range.Paragraph - IsAtStart, IsAtEnd, IsEmpty


Ad

Advertisements

J

Ji Zhou

Hello Dave,

The paragraph object has a range property that represents the whole range of
the specified paragraph. So, we can,

1. Detect whether the paragraph is empty:
We just to check the paragraph.Range.Start and paragraph.Range.End. If the
end is 1 bigger(because the paragraph Enter occupies one character space)
than the start, this paragraph is empty.
----------------------------
Sub Test()

Dim p As Paragraph
For Each p In ActiveDocument.Paragraphs
If p.Range.Start = p.Range.End - 1 Then
Debug.Print "Paragraph is empty"
End If
Next
End Sub

----------------------------

2. Detect whether a range is at Start,
We can test whether the range.Start equals to
range.Paragraph(1).Range.Start. If yes, the range is at the beginning of the
paragraph.

3. Detect whether a range is at End,
We can test whether the range.End equals to the
range.Paragraph(1).Range.End. If yes, the range is at the end of the
paragraph.


Hope this helps.


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
Ad

Advertisements

D

David Thielen

perfect - thanks - dave


Hello Dave,

The paragraph object has a range property that represents the whole range of
the specified paragraph. So, we can,

1. Detect whether the paragraph is empty:
We just to check the paragraph.Range.Start and paragraph.Range.End. If the
end is 1 bigger(because the paragraph Enter occupies one character space)
than the start, this paragraph is empty.
----------------------------
Sub Test()

Dim p As Paragraph
For Each p In ActiveDocument.Paragraphs
If p.Range.Start = p.Range.End - 1 Then
Debug.Print "Paragraph is empty"
End If
Next
End Sub

----------------------------

2. Detect whether a range is at Start,
We can test whether the range.Start equals to
range.Paragraph(1).Range.Start. If yes, the range is at the beginning of the
paragraph.

3. Detect whether a range is at End,
We can test whether the range.End equals to the
range.Paragraph(1).Range.End. If yes, the range is at the end of the
paragraph.


Hope this helps.


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support

david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

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

Similar Threads


Top