Results 1 to 12 of 12

Thread: VBA to remove all Character Styles but keep formatting

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    I was able to get it to work except it does not put the superscript back into the footnote reference number at the bottom of the page but it now deletes character styles both in the body and in the footnote text of the document. Here is the code:

    Sub DeleteFootnoteReferenceCharacterStyle()
        ' Delete footnote reference character style and replace with superscript font in the body of the document
        Selection.Find.ClearFormatting
        Selection.Find.Style = ActiveDocument.Styles("Footnote Reference")
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find.Replacement.Font
            .Bold = False
            .SmallCaps = False
            .AllCaps = False
            .Superscript = True
        End With
        With Selection.Find
            .Text = ""
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        ActiveDocument.Styles("Footnote Reference").Delete
        '  Delete all character styles in the body of the document and in footnotes
        Dim aStl As Style
        On Error Resume Next
        For Each aStl In ActiveDocument.Styles
            If aStl.Type = wdStyleTypeCharacter Then
                ActiveDocument.Styles(aStl).Delete
            End If
        Next aStl
    End Sub
    Last edited by Aussiebear; 08-10-2024 at 03:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •