View Single Post
 
Old 03-28-2024, 10:47 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 228
vivka is on a distinguished road
Default

Hi! Since "-" is a word, try the following basic code (without the exclusion check):
Code:
Sub Test()
Dim para As Paragraph
Dim oWd As range
    Application.ScreenUpdating = False
     For Each para In ActiveDocument.range.Paragraphs
      If para.Style = "Heading 1" _
      Or para.Style = "Heading 2" _
      Or para.Style = "Heading 3" _
      Or para.Style = "Report Title" _
      Or para.Style = "Report Subtitle" _
      Or para.Style = "Figure/Table Title" Then
         For Each oWd In para.range.words
            oWd.Select
            If oWd = "-" Or oWd = "(" Then
                selection.Characters.Last.Next = UCase(selection.Characters.Last.Next)
            End If
         Next oWd
      End If
     Next para
Application.ScreenUpdating = True
End Sub
Reply With Quote