How convert first letter in string to uppercase?

A

avkokin

Hello.
I need to convert first letter of every word "you" and "your" in
string to uppercase ("You" and "Your"). I wrote example of code, but
it converts all entries even into composition of words (e.g. "young").
What I should change in my code? This code is below.
Thank you.
-----------------
Sub firstLetter()
Dim aLett(3) As String
aLett(0) = "you"
aLett(1) = "your"
For ms = 0 To 1
With Selection.Find
..ClearFormatting
..Replacement.ClearFormatting
..Text = aLett(ms)
..Replacement.Text = StrConv(aLett(ms), vbProperCase)
..Forward = True
..MatchCase = True
..Wrap = wdFindContinue
..Format = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next ms
End Sub
 
G

Graham Mayor

Sub firstLetter()
Dim aLett(3) As String
Dim bLett(3) As String
aLett(0) = "you>"
aLett(1) = "your>"
bLett(0) = "You"
bLett(1) = "Your"
For ms = 0 To 1
With Selection.Find
..ClearFormatting
..Replacement.ClearFormatting
..Text = aLett(ms)
..Replacement.Text = bLett(ms)
..Forward = True
..MatchWildcards = True
..Wrap = wdFindContinue
..Format = False
End With
Selection.Find.Execute replace:=wdReplaceAll
Next ms
End Sub

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

avkokin

Sub firstLetter()
Dim aLett(3) As String
Dim bLett(3) As String
aLett(0) = "you>"
aLett(1) = "your>"
bLett(0) = "You"
bLett(1) = "Your"
For ms = 0 To 1
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = aLett(ms)
.Replacement.Text = bLett(ms)
.Forward = True
.MatchWildcards = True
.Wrap = wdFindContinue
.Format = False
End With
Selection.Find.Execute replace:=wdReplaceAll
Next ms
End Sub

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

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




- ðÏËÁÚÁÔØ ÃÉÔÉÒÕÅÍÙÊ ÔÅËÓÔ -

Thank you very much, Graham!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top