(Solved) – Running macro to specific style

(solved)-–-running-macro-to-specific-style

Below code is trying to convert words in lowercase in to uppercase. However I only need to run it only in a specific word style (“Normal”). I tried to set doc to ActiveDocument.Styles(“Normal”) but i keep on getting error. Any help would be most helpful. Thank you in advance.

Option Explicit

   Public Sub TitleCaseDocument()
   Dim doc As Document: Set doc = ActiveDocument.Styles("Normal")
   Dim wrd As Range

   For Each wrd In doc.Words
       If wrd.Text <> UCase$(wrd.Text) Then wrd.Case = wdTitleWord
Next
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *