From: mjlaali on
Hi,

how to detect that the end of a range is also end of a paragraph?
From: Graham Mayor on
There are several ways including:

Test whether the range and the last paragraph in the range have the same end
eg

If oRng.End = oRng.Paragraphs.Last.Range.End Then
'the range end is also a paragraph end.
End If

or see what the last character of the range is e.g.

If oRng.Characters.Last = Chr(13) Then
'the range end is also a paragraph end
End If
or
If oRng.Characters.Last = vbCr Then
'the range end is also a paragraph end
End If

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


"mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message
news:29AD5B4B-7296-43EC-A3AC-BE7F6174C888(a)microsoft.com...
> Hi,
>
> how to detect that the end of a range is also end of a paragraph?


From: macropod on
Hi Graham,

Not quite! Try selecting the 'paragraph mark' that defines the end of a table cell, then run the following macro:
Sub Test()
'Graham's test
MsgBox Selection.Characters.Last = Chr(13)
'Macropod's test
MsgBox Asc(Selection.Characters.Last) = 13
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Graham Mayor" <gmayor(a)REMOVETHISmvps.org> wrote in message news:uA3UTQmzKHA.4328(a)TK2MSFTNGP04.phx.gbl...
> There are several ways including:
>
> Test whether the range and the last paragraph in the range have the same end
> eg
>
> If oRng.End = oRng.Paragraphs.Last.Range.End Then
> 'the range end is also a paragraph end.
> End If
>
> or see what the last character of the range is e.g.
>
> If oRng.Characters.Last = Chr(13) Then
> 'the range end is also a paragraph end
> End If
> or
> If oRng.Characters.Last = vbCr Then
> 'the range end is also a paragraph end
> End If
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> "mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message
> news:29AD5B4B-7296-43EC-A3AC-BE7F6174C888(a)microsoft.com...
>> Hi,
>>
>> how to detect that the end of a range is also end of a paragraph?
>
>
From: Graham Mayor on
It could be argued that the table cell end marker is not a paragraph mark,
but I take your point. :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


"macropod" <macropod(a)invalid.invalid> wrote in message
news:eiwnuWmzKHA.5348(a)TK2MSFTNGP02.phx.gbl...
> Hi Graham,
>
> Not quite! Try selecting the 'paragraph mark' that defines the end of a
> table cell, then run the following macro:
> Sub Test()
> 'Graham's test
> MsgBox Selection.Characters.Last = Chr(13)
> 'Macropod's test
> MsgBox Asc(Selection.Characters.Last) = 13
> End Sub
>
> --
> Cheers
> macropod
> [Microsoft MVP - Word]
>
>
> "Graham Mayor" <gmayor(a)REMOVETHISmvps.org> wrote in message
> news:uA3UTQmzKHA.4328(a)TK2MSFTNGP04.phx.gbl...
>> There are several ways including:
>>
>> Test whether the range and the last paragraph in the range have the same
>> end eg
>>
>> If oRng.End = oRng.Paragraphs.Last.Range.End Then
>> 'the range end is also a paragraph end.
>> End If
>>
>> or see what the last character of the range is e.g.
>>
>> If oRng.Characters.Last = Chr(13) Then
>> 'the range end is also a paragraph end
>> End If
>> or
>> If oRng.Characters.Last = vbCr Then
>> 'the range end is also a paragraph end
>> End If
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> "mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message
>> news:29AD5B4B-7296-43EC-A3AC-BE7F6174C888(a)microsoft.com...
>>> Hi,
>>>
>>> how to detect that the end of a range is also end of a paragraph?
>>

From: Greg Maxey on
Sub ScratchMaco()
Dim oDoc As Word.Document
Set oDoc = Documents.Add
oDoc.Tables.Add oDoc.Range, 1, 1
MsgBox oDoc.Paragraphs.Count
End Sub

Both the end of cell and the end of row are counted as a parapraph :-(


Graham Mayor wrote:
> It could be argued that the table cell end marker is not a paragraph
> mark, but I take your point. :)
>
>
> "macropod" <macropod(a)invalid.invalid> wrote in message
> news:eiwnuWmzKHA.5348(a)TK2MSFTNGP02.phx.gbl...
>> Hi Graham,
>>
>> Not quite! Try selecting the 'paragraph mark' that defines the end
>> of a table cell, then run the following macro:
>> Sub Test()
>> 'Graham's test
>> MsgBox Selection.Characters.Last = Chr(13)
>> 'Macropod's test
>> MsgBox Asc(Selection.Characters.Last) = 13
>> End Sub
>>
>> --
>> Cheers
>> macropod
>> [Microsoft MVP - Word]
>>
>>
>> "Graham Mayor" <gmayor(a)REMOVETHISmvps.org> wrote in message
>> news:uA3UTQmzKHA.4328(a)TK2MSFTNGP04.phx.gbl...
>>> There are several ways including:
>>>
>>> Test whether the range and the last paragraph in the range have the
>>> same end eg
>>>
>>> If oRng.End = oRng.Paragraphs.Last.Range.End Then
>>> 'the range end is also a paragraph end.
>>> End If
>>>
>>> or see what the last character of the range is e.g.
>>>
>>> If oRng.Characters.Last = Chr(13) Then
>>> 'the range end is also a paragraph end
>>> End If
>>> or
>>> If oRng.Characters.Last = vbCr Then
>>> 'the range end is also a paragraph end
>>> End If
>>>
>>> --
>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>> Graham Mayor - Word MVP
>>>
>>> My web site www.gmayor.com
>>> Word MVP web site http://word.mvps.org
>>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>>
>>>
>>> "mjlaali" <mjlaali(a)discussions.microsoft.com> wrote in message
>>> news:29AD5B4B-7296-43EC-A3AC-BE7F6174C888(a)microsoft.com...
>>>> Hi,
>>>>
>>>> how to detect that the end of a range is also end of a paragraph?