|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 duquancai 于 2017-5-8 13:15 编辑
Sub 转分数2()
Dim f1$, f2$, p As Range, r As Range, n&
With ActiveDocument.Content.Find
Do While .Execute("[\-+0-9a-zA-Z]@/[\-+0-9a-zA-Z]{1,}", , , 1)
Set p = .Parent.Duplicate: Set r = p.Duplicate: n = Len(p.Text)
With .Parent
.Collapse 0: .MoveStartUntil "/", -n
f2 = .Text: r.Collapse
r.MoveEndUntil "/", n: f1 = r.Text
If Len(f1) > 0 And Len(f2) > 0 Then
p.Fields.Add p, , "EQ \f(" & f1 & "," & f2 & ")", 0
End If
.Collapse 0
End With
Loop
End With
End Sub
|
|