View Single Post
 
Old 05-20-2015, 01:41 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you are looking for sequences like
Ref.[sup]2[/sup]
to replace with
Ref.2 (with the 2 superscripted)
then the following macro will do that. (http://www.gmayor.com/installing_macro.htm)
Code:
Sub ReplaceSuperscript()
Dim oRng As Range
Const strList As String = "0123456789"
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:="Ref.[sup]")
            oRng.MoveEndUntil "]"
            oRng.End = oRng.End + 1
            oRng.Text = Replace(oRng.Text, "[sup]", "")
            oRng.Text = Replace(oRng.Text, "[/sup]", "")
            oRng.MoveStartUntil strList
            oRng.Font.Superscript = True
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Exit Sub
End Sub
If however you want to find Ref. with a superscripted number following then
Code:
Sub FindSuperscript()
Dim oRng As Range
Const strList As String = "0123456789 "
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:="Ref.")
            oRng.MoveEndWhile strList
            'Do something with the found text e.g.
            oRng.HighlightColorIndex = wdYellow
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Exit Sub
End Sub
But in the latter case you will need to indicate what you want to do with the found reference.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote