Linked Questions

Popular Questions

Finding one, not both results in Word VBA

Asked by At

I'm looking to find numbers (with formatting, so no Regex) and the following code works:

Sub FindSuperscript()

    Application.ScreenUpdating = False

    Dim contentRange As Range
    Set contentRange = ActiveDocument.Content

    contentRange.Find.ClearFormatting

    With contentRange.Find.Font
        .Bold = False
        .Italic = False
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Superscript = True
        .Subscript = False
    End With

    With contentRange.Find
        .Text = "[0-9]*>"
        .MatchWildcards = True
    End With

    contentRange.Find.Execute
    While contentRange.Find.Found
        contentRange.Find.Execute
    Wend

    Application.ScreenUpdating = True

End Sub

but it will find 10, and then 0 next when it should just find 10 and then find 11.

Related Questions