79312903

Date: 2024-12-27 22:36:28
Score: 1
Natty:
Report link

While macropod's answer didn't work, it did get me to the right track and I managed to make the code work. It might not be the most elegant solution, but it does what I need it to do:

Sub FormatTilde()

    Set TildeStyle = ActiveDocument.Styles("Approx")
    'Start from the beginning of the document
    Selection.HomeKey Unit:=wdStory
    
    With Selection.Find
        .Forward = True
        .ClearFormatting
        .MatchWholeWord = False
        .MatchCase = False
        .Wrap = wdFindContinue
        .Execute FindText:="~"
        Selection.Style = TildeStyle
        Do While Selection.Find.Execute
            Selection.Style = TildeStyle
        Loop
    End With
    
    ActiveDocument.UndoClear

End Sub

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: RankkaApina