I have VBA code that opens up a specific intranet webpage depending on the reference number, is there a way to do a VBA if statement that if a specific sentence is shown in the body of the website then it does a certain task, e.g. automatically closes the IE webpage and shows a popup message on Access saying incorrect Ref number?
Basically when the incorrect REF is given in the body of the website it reads REF ERROR, which is ideally like VBA to automatically close the website and show a popup in Access
Basically when the incorrect REF is given in the body of the website it reads REF ERROR, which is ideally like VBA to automatically close the website and show a popup in Access
Code:
Dim IE As Object
Create InternetExplorer Object
Set IE = New InternetExplorerMedium
With IE
.Visible = True
.navigate "http://corp/rf/ViewDetail.asp?Headerid=" & Mid([Forms]![FRMALLDetails]![SFRMHRDetails]. [Form]![Ref], 3, 8)
End With
For Each win In CreateObject("Shell.Application").Windows
If win.Name Like "*Internet Explorer" Then
Set IE = win: Exit For
End If
Next
'Wait for IE to load
With IE
Do Until .ReadyState = 4
DoEvents
Loop
End With
End Function