Thread: [Solved] character style
View Single Post
 
Old 05-14-2021, 11:53 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,375
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Here is the code to do the non-Greek and non-operator content. I'll leave it to you to do the rest.
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[!\<-\>\^÷" & AscW(&H374) & "-" & AscW(&H3E1) & _
        AscW(&H2C2) & "-" & AscW(&H2C7) & _
        AscW(&H1F00) & "-" & AscW(&H1FEE) & _
        AscW(&H2044) & "-" & AscW(&H208E) & _
        AscW(&H2202) & "-" & AscW(&H2265) & "]"
    .Replacement.Text = ""
    .MatchWildcards = True
    .Format = True
    .Forward = True
    .Wrap = wdFindContinue
    
    .Font.Bold = False
    .Font.Italic = True
    .Font.Subscript = False
    .Font.Superscript = False
    .Replacement.Style = "cItalic"
    .Execute Replace:=wdReplaceAll
    .Font.Subscript = True
    .Font.Superscript = False
    .Replacement.Style = "cIsub"
    .Execute Replace:=wdReplaceAll
    .Font.Subscript = False
    .Font.Superscript = True
    .Replacement.Style = "cIsup"
    .Execute Replace:=wdReplaceAll

    .Font.Bold = True
    .Font.Italic = False
    .Font.Subscript = False
    .Font.Superscript = False
    .Replacement.Style = "cBold"
    .Execute Replace:=wdReplaceAll
    .Font.Subscript = True
    .Font.Superscript = False
    .Replacement.Style = "cBsub"
    .Execute Replace:=wdReplaceAll
    .Font.Subscript = False
    .Font.Superscript = True
    .Replacement.Style = "cBsup"
    .Execute Replace:=wdReplaceAll

    .Font.Bold = True
    .Font.Italic = True
    .Font.Subscript = False
    .Font.Superscript = False
    .Replacement.Style = "cBI"
    .Execute Replace:=wdReplaceAll
    .Font.Subscript = True
    .Font.Superscript = False
    .Replacement.Style = "cBIsub"
    .Execute Replace:=wdReplaceAll
    .Font.Subscript = False
    .Font.Superscript = True
    .Replacement.Style = "cBIsup"
    .Execute Replace:=wdReplaceAll

    .Font.Bold = False
    .Font.Italic = False
    .Font.Subscript = True
    .Font.Superscript = False
    .Replacement.Style = "cSub"
    .Execute Replace:=wdReplaceAll
    .Font.Subscript = False
    .Font.Superscript = True
    .Replacement.Style = "cSup"
    .Execute Replace:=wdReplaceAll
    
    .ClearFormatting
    .Font.AllCaps = True
    .Font.SmallCaps = False
    .Replacement.Style = "cAllCaps"
    .Execute Replace:=wdReplaceAll
    .Font.AllCaps = False
    .Font.SmallCaps = True
    .Replacement.Style = "cSmCap"
    .Execute Replace:=wdReplaceAll
    
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote