View Single Post
 
Old 06-01-2021, 06:40 AM
stky stky is offline Windows 10 Office 2013
Advanced Beginner
 
Join Date: Apr 2021
Posts: 30
stky is on a distinguished road
Default need to find in main text and footnote i tried but don't know where i mistake

Code:
Sub TagtoStyle()
Dim rngStory As Range
For Each rngStory In ActiveDocument.StoryRanges
Application.ScreenUpdating = False

With ActiveDocument.StoryRanges
  With rngStory.Find
  
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "\<[! ]@\>"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  If .Find.Found = False Then
    MsgBox "No tags found", vbExclamation
  End If
  Do While .Find.Found = True
    .Style = Split(Split(.Text, "<")(1), ">")(0)
    .Text = vbNullString
    .Find.Execute
  Loop

End With
Next rngStory
    Application.ScreenUpdating = True
End Sub
Reply With Quote