且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从Microsoft Word文档中删除超链接?

更新时间:2023-02-21 20:31:39

这是一篇旧帖子,所以我添加这个VBA代码,以防它对某人有用。

This is an old post, so am adding this VBA code in case it is useful to someone.

需要以相反的顺序删除超链接(集合) :

Hyperlinks (Collections) need to be deleted in reverse order:

Sub RemoveHyperlinksInDoc()
    ' You need to delete collection members starting from the end going backwards
    With ActiveDocument
        For i = .Hyperlinks.Count To 1 Step -1
            .Hyperlinks(i).Delete
        Next
    End With 
End Sub

Sub RemoveHyperlinksInRange()
    ' You need to delete collection members starting from the end going backwards
    With Selection.Range
        For i = .Hyperlinks.Count To 1 Step -1
            .Hyperlinks(i).Delete
        Next
    End With    
End Sub