The macro I'm developing is designed to launch from a button. The button triggers a looping sub that simply fires the sub's child process which does most of the work.
The child process loads a URL in IE and then navigates to a report screen. Following that it waits a specified pored of time (in the flow the value is X. When X is exceeded IE is closed and control is surrendered back to the parent which waits 10 seconds before relaunching the sub.
The problem comes into play when X is changed to one hour from my 10 second test timer. I'm suspecting that there is something in VBA Excel that decays so after about five minutes I get the error (which doesn't make a lot of sense to me).
Interested in finding out what the time change does to break this and see if anyone knows of a way around the problem.
Code below... Thanks in advance!
Private Sub OpenReport()
Dim text As String
Dim x As Integer
Dim IE
Set IE = New InternetExplorerMedium
text = "PCode"
'Load link
IE.Visible = True
IE.Navigate "http://~~~~~~~~~~~~.net/reports/views/result/reportResult.faces"
'Wait for page to load
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
'fill in the pcode
IE.Document.getelementbyid("Pcode").Value = text
'Click Submit
IE.Document.getElementsByClassName("btn btn-lg btn-primary btn-block")(0).Click
'Wait for page to load
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
'Click on Favorites
IE.Document.getElementsByClassName("myMRSFavoritesLink")(0).Click
'Wait for page to load
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
'Click on report
IE.Document.getElementsByName("myFavoritesForm:treeTable_tableId:6:infoButton98772406j_id__v_55")(0).Click
'Wait for page to load
Do While IE.Busy Or IE.ReadyState <> 4
DoEvents
Loop
IE.Document.getElementsByName("setParametersForm:startReportButton")(0).Click
'Wait for a period of time contained in TimeValue
Application.Wait (Now + TimeValue("00:01:00")) ' This is X
'Close IE
IE.Quit
End Sub
Private Sub CommandButton1_Click()
Dim Looper As Long
Looper = 0
Do While Looper < 1
Application.Wait Now + TimeValue("00:00:10")
Call OpenReport
Loop
End Sub