如何以编程方式编辑 Word 文档中的所有超链接? [英] How to programmatically edit all hyperlinks in a Word document?

查看:21
本文介绍了如何以编程方式编辑 Word 文档中的所有超链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is there a macro, VBA code or VBScript that I can write to edit the urls of all the hyperlinks in my Word document? Either Word 97-2003 or docx format.

推荐答案

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

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

这篇关于如何以编程方式编辑 Word 文档中的所有超链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆