VBA for Word; Capitalization of part of a sentence

In Access 2007 I am writing to a Word document using Ranges instead of Selections. I want to capitlaize the first 5 words of a phrase ending with a colon. I use the following code which works, but was wondering if this can be done without using a For loop.
 
        .InsertAfter vbCr & "Status on Admission to CareConnect: "
        .InsertAfter rs("CC_OriginalStatus").Value
        .Paragraphs.Last.Range.Font.Bold = False
        Dim i As Integer
        For i = 1 To 5 Step 1
            .Paragraphs.Last.Range.Words(i).Font.Bold = True
        Next
jbottsAsked:
Who is Participating?
 
GrahamSkanRetiredCommented:
You can doi somethig like this:

Function Capitalise(BigRange As Range) As String
    Dim rng As Range
   
    Set rng = BigRange
    rng.End = BigRange.Words(5).End
    Debug.Print rng.Text
    rng.Case = wdUpperCase
    Debug.Print rng.Text
   
End Function
0
 
jbottsAuthor Commented:
Thanks for the information. This with some self education about ranges in Word solved the problem. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.