View Single Post
 
Old 03-16-2022, 08:44 AM
ievakr ievakr is offline Windows 10 Office 2019
Novice
 
Join Date: Mar 2022
Posts: 1
ievakr is on a distinguished road
Question Hyperlink.Delete does not work properly

Hello,
What I want to do, is for macro to find all hyperlinks with word "servlet" in the address and delete the hyperlink:

Code:
Sub Link()


Dim H As Hyperlink
    For Each H In ActiveDocument.Hyperlinks
        If InStr(H.Address, "servlet") <> 0 Then
            H.Delete
        End If
    Next H
End Sub
But H.Delete breaks the Next H function and in result only every second hyperlink is deleted and I have to run the macro again. Meanwhile H.Follow works like a charm in this code.
What can it be?