Hello Dave,
The workbok now contains 2 links. One in "A1" and another in "A2". I checked "A1" and it is no longer on the Google page. The link in "A2" is valid. I added a button to call the macro. When the macro is run from the VBIDE, the message box appears while Internet Explorer is active. The message box appears behind Excel while Internet Explorer is active. The message box now is displayed after IE is closed. Here is the updated code. These changes have been made to the attached workbook,
Sub CheckLink()
Dim IEapp As Object
Dim IEdoc As Object
Dim Href As String
Dim Msg As String
Dim Res As Variant
Dim Site As String
Site = "www.google.com"
Href = Range("A2")
Set IEapp = CreateObject("InternetExplorer.Application")
IEapp.Navigate Site
While IEapp.Busy
DoEvents
Wend
Set IEdoc = IEapp.Document
For Each Item In IEdoc.Links()
Res = InStr(1, Item.outerhtml, Href)
If Res Then
Msg = "Link has Not Changed"
GoTo Finish
End If
Next Item
Msg = "Link has been Updated."
Finish:
IEapp.Quit
Set IEapp = Nothing
Set IEdoc = Nothing
MsgBox Msg
End Sub
Bookmarks