Log in

View Full Version : VBA to remove random capitalizations



isabelle r
05-23-2024, 06:09 AM
Hello,

I'm working on editing a high number of PPT presentations submitted by multiple people from different places around the world. Just correcting the grammar and spelling would be a pain, but most submitters also seem to have one infuriating thing in common: adding unnecessary capitalization to random words in the middle of a sentence (a little Bit like This, which is Really irritating to Correct, because I then Need to Manually Select that one initial Letter and retype it).

Could a kind soul please make a VBA which would convert all words in a slide starting with an uppercase letter to lowercase, except for words at the beginning of a sentence (and the word "I")? If there could additionally be a list of exceptions (i.e. words where the initial letter needs to remain capitalised) which I could complete manually in the VBA, that would be great, but just converting everything except the first word in a sentence to lowercase would be a time- and sanity-saver.

Thank you in advance for any help you can offer me.

-Isa

Aussiebear
05-23-2024, 02:30 PM
Welcome to VBAX isabelle r. Perhaps this will get you started


Public Function PropCaps(varLastName) As Variant
'Purpose : Proper capitalization of names with more than one Cap such as D'Angelo, O'Brein, McDonald.
'Note: does not attempt names like MacDoogal. Too many exceptions with names starting with Mac.
'DateTime : 5/05/2000
'Author : Bill Mosca
Dim varOut As Variant
Dim intPos As Integer
If IsNull(varLastName) Then Exit Function
'Irish
intPos = InStr(1, varLastName, "MC", vbTextCompare)
If intPos > 0 Then
varOut = StrConv(Left(varLastName, 2), vbProperCase) _
& StrConv(Mid(varLastName, 3), vbProperCase)
End If
'Various ancestry.
intPos = InStr(varLastName, "'")
If intPos > 0 Then
varOut = StrConv(Left(varLastName, intPos), vbProperCase) _
& StrConv(Mid(varLastName, intPos + 1), vbProperCase)
End If
PropCaps = varOut
End Function

John Wilson
05-25-2024, 10:39 PM
You could probably save a lot of time by selecting the Text and changing to 'Sentence Case' from the Font Section. You could do this with vba but even manually should save time.

31588