I need a bit of code for a Word macro that will capitalize the first letter of a word if it's not already capitalized. But if it is already capitalized, then I don't want it changed.
My current macro uses Shift-F3, which is Word's toggle between cap/not cap. It works great when the target word is lower case, but if the word is already capped, it lower cases it, which is not what I want.
So, here's the situation in which I would use it. Say there's a run-on sentence like this:
Mary likes apples Tom likes oranges.
I want to put my cursor after the s in apples and run the macro. The macro should type a period, move over one space, add a second space, select the T in Tom, and capitalize it if it's not capitalized and leave it alone if it is capitalized. Then I want the cursor to end up just to the left of the T in Tom.
And here's my current code:
' insertaperiod Macro
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Range.Case = wdNextCase
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=" "
Thank you to this very helpful group!