如何以编程方式编辑Word文档中的所有超链接?

jin*_*ngy 12 vbscript ms-word word-vba

是否有我可以编写的宏,VBA代码或VBScript来编辑我的Word文档中所有超链接的URL?Word 97-2003或docx格式.

Tes*_*101 14

Dim doc As Document
Dim link, i
'Loop through all open documents.
For Each doc In Application.Documents
    'Loop through all hyperlinks.
    For i = 1 To doc.Hyperlinks.Count
        'If the hyperlink matches.
        If LCase(doc.Hyperlinks(i).Address) = "http://www.yahoo.com/" Then
            'Change the links address.
            doc.Hyperlinks(i).Address = "http://www.google.com/"
            'Change the links display text if desired.
            doc.Hyperlinks(i).TextToDisplay = "Changed to Google"
        End If
    Next
Next
Run Code Online (Sandbox Code Playgroud)

这是所有超链接方法和属性链接

  • 这不适用于带有超链接的图像= /你知道如何获得这些吗? (2认同)