View Single Post
 
Old 10-17-2023, 10:00 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 200
RobiNew is on a distinguished road
Question Perfect macro not working when its code is inserted in larger macro

I devised the macro here below to apply Superscript to the last character of a five digit string. It works perfectly, but when I insert the code in a larger macro the last character remains intact. Can someone help? Thanks!

Code:
Dim oRng As Range, iType As Integer
  For iType = 1 To 2
    Set oRng = ActiveDocument.StoryRanges(iType)
    With oRng.Find
      .ClearFormatting
      .Text = "^#^#^#^#^#"
      While .Execute
        oRng.Collapse wdCollapseEnd
        oRng.MoveStart Unit:=wdCharacter, Count:=-1
        oRng.Font.Superscript = True
      Wend
    End With
  Next iType
Reply With Quote