如何以编程方式编辑Word文档中的所有超链接? [英] How to programmatically edit all hyperlinks in a Word document?
本文介绍了如何以编程方式编辑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屋!
查看全文