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

标签 vbscript ms-word

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

最佳答案

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

这是所有 Hyperlink Methods and Properties 的链接

关于vbscript - 如何以编程方式编辑 Word 文档中的所有超链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3355266/

相关文章:

c++ - 当使用 CreateObject 从 VBScript 通过 COM 引用 C++ DLL 时,如何处理 DLL 版本?

javascript - 如何以编程方式更改此下拉菜单中的所选项目?

excel - 从 Excel 复制到 Word 文档时出现剪贴板错误

c# - OpenXML 将文本插入内容控件 Word 2007

vba - 如何使用宏 vba-Word 更新表格?

windows - 在子文件夹中运行 .vbs

image - QTP 如何保存网页中的图像

excel - VBScript 从 Excel 到 Word

html - 居中和右对齐

excel - 从 VBA Excel 打开和关闭 Word 文档