A family of Microsoft word processing software products for creating web, email, and print documents.
Ok.
That helps.
First up, remember that the No-width break is not a space--it has no width, and so should not cause problems, although if the document is converted to another format in the typesetting, it's anyone's guess whether the non-width break will be converted correctly.
Second, the big deal isn't really a big deal at all. It's just what I would consider, if I were doing this, to be best practice. Certainly it would have simplified the macro quite a bit.
Third, I think (but I'm guessing) that your mixed results with the capitilization after Chr(147) comes from a mixture of smart and straight quotes in your document. See how I corrected for that below. And seeing as we are targeting a single character there, why let Word guess what it should be? So I changed wdTitleWord to wdUppercase.
Then, your strings for .Characters(j) = ": " & Chr147 [etc.] didn't work because you are comparing a 1-character string [.Characters(j)] to a 2-character string [": "]. The result will always be false.
Fifth, the multiple if statements just complicate matters, so I just conflated all of it into one comparison with Like.
I still think the macro below as I modified it is terribly inefficient, but it does the job on the samples you provided.
Let me know if it works for you.
Sub HeadingCap()
Dim StrStyles As String, strLength As String
Dim sQuotes As String
Dim i As Long, j As Long
StrStyles = "HedStyle1|HedStyle2|HedStyle3"
sQuotes = Chr(34) & Chr(147) 'Probably no need to add chr(148)?
For i = 0 To UBound(Split(StrStyles, "|"))
With ActiveDocument.Content
With .Find
.Style = Split(StrStyles, "|")(i)
.Format = True
.Wrap = wdFindStop
.Forward = True
.Text = ""
.Execute
End With
Do While .Find.Found
'exclude typesetting code
.MoveStart Unit:=wdCharacter, Count:=4
'lc everything
.Case = wdLowerCase
'cap first letter
.Characters(IIf(InStr(1, sQuotes, .Characters.First, vbTextCompare) > 0, 2, 1)).Case = wdUpperCase
'cap letters after "[:?!] "
strLength = .Characters.Count
For j = 1 To strLength
If .Characters(j) Like "[:?!""“]" Then _
.Characters(j + IIf(.Characters(j + 1) Like " ", 2, 1)).Case = wdUpperCase
'cap turq-highlighted letters
If (.Characters(j).HighlightColorIndex = wdTurquoise) = True Then
.Characters(j).Case = wdUpperCase
.Characters(j).HighlightColorIndex = wdNoHighlight
End If
Next j
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Next i
End Sub