Group:  Microsoft Word ยป microsoft.public.word.vba.beginners
Thread: Select last word of paragraph

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Select last word of paragraph
"GD1" <euthymos[ at ]gmail.com> 26.09.2006 18:15:04
How can I select the last word of a certain paragraph?

Thank you :)

Re: Select last word of paragraph
"Tony Jollans" <my forename at my surname dot com> 26.09.2006 19:19:26
Depending on what you mean by 'word' this is probably harder than you might
imagine. Something like this should normally work ...

Dim ParaRef As Paragraph
Dim WordNum As Long

' Get a reference to your paragraph, for example
Set ParaRef = ActiveDocument.Range.Paragraphs(1)

' Scan backwards, avoiding para mark and punctuation
For WordNum = ParaRef.Range.Words.Count To 1 Step -1
If Len(ParaRef.Range.Words(WordNum)) > 1 Then
ParaRef.Range.Words(WordNum).Select
Exit For
End If
Next

--
Enjoy,
Tony

"GD1" <euthymos[ at ]gmail.com> wrote in message
news:1159294504.754943.226690[ at ]i3g2000cwc.googlegroups.com...
[Quoted Text]
> How can I select the last word of a certain paragraph?
>
> Thank you :)
>


Re: Select last word of paragraph
"Jezebel" <warcrimes[ at ]whitehouse.gov> 26.09.2006 21:50:07
Depends on your definition of 'word' -- if you use VBA's, then --

selection.Range.Paragraphs(1).Range.Words(selection.Range.Paragraphs(1).Range.Words.Count).Select




"GD1" <euthymos[ at ]gmail.com> wrote in message
news:1159294504.754943.226690[ at ]i3g2000cwc.googlegroups.com...
[Quoted Text]
> How can I select the last word of a certain paragraph?
>
> Thank you :)
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net