I’m trying to capitalize the first letter of each word in a document and leave the rest of the word in camelCase.
So as an example:
wordExample
becomes
WordExample
I’ve tried many different variations of the following code (this is the simplest one), but every one of them crashes my MS Word instance on my Mac.
I’m running Word 16.87 and macOS is 14.5
Any help will be greatly appreciated. Thanks in advance. – CES
Sub CapitalizeFirstLetterOnly()
Dim doc As Document
Dim word As Range
Dim firstLetter As String
Dim restOfWord As String
Set doc = ActiveDocument
For Each word In doc.words
firstLetter = UCase(Left(word.Text, 1))
restOfWord = Mid(word.Text, 2)
word.Text = firstLetter & restOfWord
Next word
End Sub