Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Internet Explorer question - Refresh
Sometimes after I fire up my IE session, I get a 'web page is not available'
error. If I then click 'Refresh' (or go ieAmeritrade.refresh), the login page loads correctly. 1) Is there a way to test before the Do loop to see if I have gotten the real page or an error page? 2) What is the variable type of ipf? Public Sub InitAmeritrade() Dim ieAmeritrade As InternetExplorer Set ieAmeritrade = New InternetExplorer ieAmeritrade.Visible = True ieAmeritrade.Navigate "https://wwws.ameritrade.com/cgi-bin/spec_login.cgi?SP=LTC" Do Until ieAmeritrade.ReadyState = READYSTATE_COMPLETE DoEvents Loop 'Log on Set ipf = ieAmeritrade.Document.all.Item("USERID") |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Internet Explorer question - Refresh
First of all this will not be before the do loop but after it and the do loop has to be used again after refresh. Then, If IEObject.ReadyState = READYSTATE_COMPLETE may not work some times, especially when refreshed. If the page is completely loaded, IE sometimes keep giving readystate as still loading. Therefore another condition (if the statustext conatins word "Done") need to be added to exit the do loop otherwise the do loop may go in infinite loop. Third, the page error can be error generated because IE can not resolve the URL address to IP address, (either DNS error, or internet link down) OR the web site itself may generate error page (requested page not found or temporarily down etc.) Therefore, I thought the better way would be check if on the loaded page, Item("USERID") exists or not, if not, then refresh. Simple loop of keeping refreshing if above error found, may again land in an infinite loop if internet link is down or DNS error. Therefore better to do refresh a certain no. of times, still if the page is not loaded, giver error message and exit. Below code will try refreshing 3 times: Public Sub InitAmeritrade() Dim ieAmeritrade As InternetExplorer, n As Integer Set ieAmeritrade = New InternetExplorer ieAmeritrade.Visible = True ieAmeritrade.Navigate _ "https://wwws.ameritrade.com/cgi-bin/spec_login.cgi?SP=LTC" n = 1 WaitLoop: Do Until ieAmeritrade.ReadyState = READYSTATE_COMPLETE DoEvents If InStr(1, ieAmeritrade.StatusText, "Done") _ 0 Then Exit Do Loop Set ifp = ieAmeritrade.Document.All.Item("USERID") Err.Clear On Error Resume Next If IsError(ifp.Name) Then If n 3 Then MsgBox "Refreshing 3 times did not help" 'Instead of msgbox you can put a code to 'write log in to a cell 'could not open site' ieAmeritrade.Quit Exit Sub End If n = n + 1 ieAmeritrade.Refresh GoTo WaitLoop: End If On Error GoTo 0 'Your remaining code from ifp = "Username" onwards. End Sub *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Internet Explorer question - Refresh
Mr Sharad:
You have been a great help to me, and I thank you very much. This has shown me several new ideas which I need to incorporate as well as having answered several as yet un-asked questions. -Tim "Sharad" wrote in message ... First of all this will not be before the do loop but after it and the do loop has to be used again after refresh. Then, If IEObject.ReadyState = READYSTATE_COMPLETE may not work some times, especially when refreshed. If the page is completely loaded, IE sometimes keep giving readystate as still loading. Therefore another condition (if the statustext conatins word "Done") need to be added to exit the do loop otherwise the do loop may go in infinite loop. Third, the page error can be error generated because IE can not resolve the URL address to IP address, (either DNS error, or internet link down) OR the web site itself may generate error page (requested page not found or temporarily down etc.) Therefore, I thought the better way would be check if on the loaded page, Item("USERID") exists or not, if not, then refresh. Simple loop of keeping refreshing if above error found, may again land in an infinite loop if internet link is down or DNS error. Therefore better to do refresh a certain no. of times, still if the page is not loaded, giver error message and exit. Below code will try refreshing 3 times: Public Sub InitAmeritrade() Dim ieAmeritrade As InternetExplorer, n As Integer Set ieAmeritrade = New InternetExplorer ieAmeritrade.Visible = True ieAmeritrade.Navigate _ "https://wwws.ameritrade.com/cgi-bin/spec_login.cgi?SP=LTC" n = 1 WaitLoop: Do Until ieAmeritrade.ReadyState = READYSTATE_COMPLETE DoEvents If InStr(1, ieAmeritrade.StatusText, "Done") _ 0 Then Exit Do Loop Set ifp = ieAmeritrade.Document.All.Item("USERID") Err.Clear On Error Resume Next If IsError(ifp.Name) Then If n 3 Then MsgBox "Refreshing 3 times did not help" 'Instead of msgbox you can put a code to 'write log in to a cell 'could not open site' ieAmeritrade.Quit Exit Sub End If n = n + 1 ieAmeritrade.Refresh GoTo WaitLoop: End If On Error GoTo 0 'Your remaining code from ifp = "Username" onwards. End Sub *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Internet Explorer | Excel Discussion (Misc queries) | |||
internet explorer instance | Excel Discussion (Misc queries) | |||
Internet explorer download/XP Pro?? | Excel Discussion (Misc queries) | |||
Internet explorer problem | Excel Discussion (Misc queries) | |||
internet explorer | Excel Discussion (Misc queries) |