How do you remove hyperlinks from a Microsoft Word document?

前端 未结 2 568
挽巷
挽巷 2021-01-25 06:45

I\'m writing a VB Macro to do some processing of documents for my work. The lines of text are searched and the bracketed text is put in a list(box).

The problem comes w

2条回答
  •  清酒与你
    2021-01-25 07:11

    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
    

提交回复
热议问题