我想仅用http://www.someurl.com替换下面的文字。我有Word mac 2011.为了澄清,我实际上并不想从字段代码返回到实际的超链接(蓝色),我只想将地址作为文档中的文本。
{HYPERLINK“http://www.someurl.com”}
答案 0 :(得分:0)
这样的东西(但请注意它不会处理嵌套字段),除非您更改Word首选项,否则Word会在您开始编辑结果时重新插入链接:
Sub replaceHLs()
Dim hl As Word.Hyperlink
Dim i As Integer
Dim r As Word.Range
Dim strLinkText As String
For i = ActiveDocument.Hyperlinks.Count To 1 Step -1
With ActiveDocument.Hyperlinks(i)
Set r = .Range
strLinkText = .Address
' optional, should be OK for HTML links
If .SubAddress <> "" Then
strLinkText = strLinkText & "#" & .SubAddress
End If
r.Text = strLinkText
r.Font.Color = wdColorBlue
r.Font.Underline = wdUnderlineSingle
Set r = Nothing
End With
Next
End Sub