如何在 VBA MS Word 2003 文档中将所有升高/降低字符更改为 上标/下标字符?
我的非功能代码:
Public Sub Normalize_Position()
Application.ScreenUpdating = False
Dim uVals() As Variant
Dim Rng As Range
'All these values are font positions
uVals = Array(0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5)
For v = 0 To UBound(uVals)
With Selection
.HomeKey Unit:=wdStory
Set Rng = ActiveDocument.Range
Rng.Collapse Direction:=wdCollapseStart
Rng.Find.ClearFormatting
Rng.Find.Font.position = uVals(v)
Rng.Find.Replacement.ClearFormatting
With Rng.Find
.Text = ""
.Replacement.Text = ""
.Replacement.Font.position = 0
.Replacement.Font.Superscript = 1
.Replacement.Font.Color = wdColorRose
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Rng.Find.Execute Replace:=wdReplaceAll
End With
Next
Application.ScreenUpdating = True
'Free up memory
ActiveDocument.UndoClear
Debug.Print "Normalize font position Finished.!"
End Sub