![]() |
|
|
|
#1
|
||||
|
||||
|
That's what your example showed. If you want to check the last word in the document against the list, then set the range end there instead. e.g.
Code:
Sub Macro1()
'Graham Mayor - http://www.gmayor.com - Last updated - 12 Jan 2018
Dim oRng As Range
Dim strEndWord() As Variant
Dim i As Long
strEndWord = Array("so", "jas", "mf")
Set oRng = Selection.Paragraphs(1).Range
With oRng
.Font.Bold = True
.End = .Words(1).End - 1
.InsertAfter ChrW(9658)
.End = .End + 1
.Font.ColorIndex = wdRed
.End = ActiveDocument.Range.End - 1
.Start = .Words.Last.Start
For i = 0 To UBound(strEndWord)
If strEndWord(i) = LCase(.Text) Then
.InsertBefore vbTab
.Font.Bold = True
Exit For
End If
Next i
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#2
|
|||
|
|||
|
I don't understand properly. Where I should set the range end?
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Setting part of a paragraph bold | Fred256 | Word VBA | 4 | 10-07-2016 02:54 PM |
| How to parse bold sections of a paragraph? | XmisterIS | Word VBA | 2 | 03-31-2014 02:54 PM |
Set paragraph text to bold.
|
Sorcerer13 | Word | 1 | 09-04-2012 11:08 AM |
Word doesn't jumps tothe next lane when finds the dash sign!!!! why?
|
Jamal NUMAN | Word | 3 | 04-10-2011 02:49 PM |
| paragraph sign appearing in document | ajetrumpet | Word | 1 | 08-24-2010 05:46 AM |