|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 praijna 于 2017-7-17 20:28 编辑
老师:
您好!
如下语句,执行加超链接的时候,就进入死循环,始终停在第一个上标处,如何解决?
Sub shishi()
Dim fi As Field
Dim i As Paragraph, mt, oRang As Range, N%, m%
With CreateObject("vbscript.regexp")
.Pattern = "\([0-9]+\)"
.Global = True: .IgnoreCase = False: .MultiLine = True
For Each fi In ActiveDocument.Fields
fi.Select
S = Selection
For Each mt In .Execute(S)
If mt <> "" Then
cljmz = "传灯序" & Format(Split(Split(S, "(")(1), ")")(0), "000")
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, SubAddress:=cljmz(执行这句后,就死循环了)
End If
Next
Next
End With
End Sub
感恩!
file:///C:\Users\Prajna\Documents\Tencent Files\528692676\Image\C2C\5)AVHT52W``1FMS(M$FWR]N.png
|
|