The purpose of this code is to do a simple search for a using the website's own search box. This code was placing code into the search box and clicking the website's search button. However, I am not sure what has recently changed to prevent the code from executing. The html website element ID tags have not appeared to have changed yet the Readystate error continues to be where the code is failing. I am using IE 11 on my computer. Here is the code that was working with previous IE versions:
I have attempted the following with no success of correcting my current problem:
1) I attempted to replace SHDocVw.InternetExplorer with InternetExplorerMedium
2) I have tried both Security settings of: Enabled Protective Mode and Disabled Protective Mode
PLEASE let me know what I am not doing correctly. Any suggestions would be extremely appreciated.
Thank You.
Code:
Dim objIE As SHDocVw.InternetExplorer 'microsoft internet controls (shdocvw.dll)
Dim htmlDoc As MSHTML.HTMLDocument 'Microsoft HTML Object Library
Dim htmlInput As MSHTML.HTMLInputElement
Dim htmlColl As MSHTML.IHTMLElementCollection
Set objIE = New SHDocVw.InternetExplorer
With objIE
.navigate "http://XYZ" ' Main page
.Visible = 1
Do While .Busy: DoEvents: Loop
Do While .readyState <> 4: DoEvents: Loop
Set htmlDoc = .document
Set htmlColl = htmlDoc.getElementsByTagName("INPUT")
For Each htmlInput In htmlColl
If htmlInput.Name = "search" Then
htmlInput.Value = Replace(Range("A1").Value, " ", "_")
End If
Next htmlInput
Set htmlDoc = .document
Set htmlColl = htmlDoc.getElementsByTagName("input")
Do While htmlDoc.readyState <> "complete": DoEvents: Loop
For Each htmlInput In htmlColl
If htmlInput.Name = "go" Then
htmlInput.Click
End If
Next htmlInput
End With
I have attempted the following with no success of correcting my current problem:
1) I attempted to replace SHDocVw.InternetExplorer with InternetExplorerMedium
2) I have tried both Security settings of: Enabled Protective Mode and Disabled Protective Mode
PLEASE let me know what I am not doing correctly. Any suggestions would be extremely appreciated.
Thank You.