ucase function

G

Guest

Hi,

I know there is a Ucase function and an Lcase function.

Is there a function that just capitalises the first letter of a word and
make the remaining letter of the word all lowercase.

That is will make powerpoint -> Powerpoint

Thanks
 
G

Greg

Try something like:

Sub FirstCap()
Dim myRng As Range
Set myRng = Selection.Range
myRng.Case = wdTitleWord
End Sub
 
J

Jay Freedman

nospam said:
Hi,

I know there is a Ucase function and an Lcase function.

Is there a function that just capitalises the first letter of a word
and make the remaining letter of the word all lowercase.

That is will make powerpoint -> Powerpoint

Thanks

Greg's example will change the capitalization of text in the body of a
document, which may be what you want. If you're dealing with a string
variable in memory, you can do this:

myStr = UCase(Left(myStr, 1)) & LCase(Mid(myStr, 2))
 
J

Jezebel

Strictly, the brief didn't call for de-capitalising the rest of the string.
Better --

myStr = UCase$(Left$(myStr, 1)) & Mid$(myStr, 2)


Separately, the string version of these functions is about 1000 times faster
than the variant version. (Entirely irrelevant unless you're calling them
repeatedly.)
 

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