View Single Post
Old 09-06-2019, 02:44 PM
jeffreybrown jeffreybrown is offline Windows 10 Office 2016
Join Date: Apr 2016
Posts: 600
jeffreybrown will become famous soon enoughjeffreybrown will become famous soon enough

No worries Greg. Thanks for the follow-up.


I suppose I'm still doing something wrong here. I placed that bit of text after the line:
With Selection.Range, but it only fixes the last entry in the selection. I stepped thru the code and can see it looping, but it doesn't loop one paragraph at a time.

Sub MakeTitle()
    Application.ScreenUpdating = False
    Dim StrTmp As String
    With Selection.Range
        Do While InStr(.Text, Chr(151)) > 0
            .Start = .Start + InStr(.Text, Chr(151))
            StrTmp = Trim(.Text)
        While Right(StrTmp, 1) = "."
            StrTmp = Left(StrTmp, Len(StrTmp) - 1)
        While InStr(StrTmp, "  ") > 0
            StrTmp = Replace(StrTmp, "  ", " ")
        StrTmp = TitleCase(StrTmp, bCaps:=False, bExcl:=True)
        .Text = StrTmp
    End With
    Application.ScreenUpdating = True
End Sub
I don't have any periods in these paragraphs so I would suppose the part in Red is not necessary?
Attached Files
File Type: docm TestFile.docm (26.3 KB, 1 views)
Reply With Quote