How would I allow the following Content Control formatting, but compile a string of words or characters that if present in the TextBox on a UserForm, were not included in the two lines of formatting intruction?
For the vbProperCase I would like to exclude words like "the, and, it, if, so" so they would all be LowerCase if found.
For the UCase Words, I need it to exclude commas and full stops (this is because at the moment, if one is found at the end of the text entry, it treats that as the last word and effectifly capitilises it instead of the real last actual word).
Finally, if there is a hyphen immediately to the left of the vbProperCase selected last word, then the word to the left of the hyphen should also have UCase applied too.
I'm thinking that this would probably involve producing three variable strings which contain the various words / punctuation marks combinations, then putting in some "If InStr, else, else if" code.
(I've removed all the other Case select options from the below)
Sub FillForm()
Dim oCtrl As Control
Dim oCC As ContentControl
Dim oRng As Range
Dim lngIndex As Long
Dim strTC As String
With m_oFrm
For Each oCtrl In .Controls
Select Case TypeName(oCtrl)
Case "TextBox"
If oCtrl.Name = "txtKeys" Then
Set oRng = ActiveDocument.SelectContentControlsByTag("Keys").Item(1).Range
oRng.Text = StrConv(oCtrl.Text, vbProperCase)
oRng.Words.Last = UCase(oRng.Words.Last)
End If
End Select
Next oCtrl
End With
lbl_Exit:
Exit Sub
End Sub
Thanks!
Steve