|
想把word文档中的文字,如:20km^2等“^2”形式的批量转化为上标2(删除了^号),不知如何实现,请老师帮忙。谢谢!
代码如下:
Dim col As New Collection, k&
Dim i As Paragraph, mt, oRang As Range, n%, m%
With CreateObject("vbscript.regexp")
.Pattern = "([\^])([0-9]{1,})"
.Global = True: .IgnoreCase = False: .MultiLine = True
For Each i In ActiveDocument.Paragraphs
For Each mt In .Execute(i.Range.Text)
k = k + 1
m = mt.FirstIndex: n = mt.Length
Set oRang = ActiveDocument.Range(i.Range.Start + m, i.Range.Start + m + n)
col.Add oRang, CStr(k)
oRang.Font.Superscript = True
Next
Next
End With
For j = 1 To col.Count
col(j) = 替换成上面的数字,不知如何表达?
Next
|
|