Quote:
Originally Posted by macropod
Word's TitleCase function is a fairly blunt instrument that crudely capitalises the first letter of each word and destroys the capitalisation for acronyms and various surnames, for example. Such an approach really doesn't conform to the usual understanding title casing.
…………
To re-format just a selection, you could call the function with a macro like:
Code:
Sub MakeTitle()
Application.ScreenUpdating = False
Dim StrTmp As String
With Selection.Range
StrTmp = Trim(.Text)
While Right(StrTmp, 1) = "."
StrTmp = Left(StrTmp, Len(StrTmp) - 1)
Wend
While InStr(StrTmp, " ") > 0
StrTmp = Replace(StrTmp, " ", " ")
Wend
StrTmp = TitleCase(StrTmp, bCaps:=False, bExcl:=False)
.Text = StrTmp
End With
Application.ScreenUpdating = True
End Sub
…………
|
This technique destroys any character formatting within the selection, such as change of fonts. Is there a simple way to replace the text of the range with the new version, while preserving the original formatting?