We help IT Professionals succeed at work.

Converting the first letter into Upper case

Ravindra_Nag
Ravindra_Nag asked
on
Hi,
I need to convert the first letter of every line into upper case for the lines that have been selected. I have been able to use VBA code from this forum to do it for active paragraph. The VBA code is pasted below:
Sub UcaseLetter1()
    Selection.Paragraphs(1).Range.Words(1).Characters(1).Text = UCase$(Selection.Paragraphs(1).Range.Characters(1).Text)

With ActiveDocument.Paragraphs(1).Range.Characters(1)
    .Font.SmallCaps = False
    .Text = UCase$(.Text)

End With
End Sub

I am looking into modification of this code to cover the entire selection.  
Comment
Watch Question

Retired
Top Expert 2012
Commented:
Try it this way
Sub UcaseLetter1()
    Dim para As Paragraph
    For Each para In Selection.Paragraphs
        para.Range.Characters.First.Case = wdUpperCase
    Next para
End Sub

Open in new window

Author

Commented:
Thank you Graham