Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
Readystate in IE in VBA program

in my code that means sometimes it work ok but sometimes is not working, I have used "Debug.print" to
check where is error, found at Code-line-11, .document.all("login").click has issue with Readystate
we use .navigate to grab the website in first time , Readystate and Busy state of IE will be good flag to see
the IE ready and busy or not. So checkreadystate function is okay for first time to explore IE. But When I use .doucment.all("Login").click to change to second other website page, it seems Readystate and Checkreadystate function desn't help much for waiting/monitor "login" page is ready and busy or not. I guess the is because Readystate is already set by first time to nagviate "http://example.com" if successfully at(code-line-7) And the user could not change the state of REadystate except quit the IIE windows. So, I try to put put code-line-13, adding Sleep(3000) for 3 seconds delay, the VBA code works fine. And sometime we also put back code-line-6 make it .Visible IE windows, it also work but not all the times. It seems the issue and error is not stable at all that might be related to timming of loading the "Login" page. Is there any method to check When the second time of loading page is ready and busy or not but be reminded it is second time loading page after nagviate the first page
I mean first time of loading page, for example, first time to navigate IE explorer and seoncd time loading page
means you have to base on the first page is ready in order to access the second website, Just similar to
when you login your bank website.
I don't want to use Sleep(3000) function and .Visible to let second loading page is ready first before we are
running our rest of our program code. What is suggestion to solve this issue ? If you understand my issue, please let me know. I will explain more. Please advise
Br
Duncan
1-Dim myIE As SHDocVw.InternetExplorer 'Need Microsoft Internet Controls reference selected
2-Set myIE = Nothing
3-Set myIE = CreateObject("InternetExplorer.Application")
4-Set myIE = New InternetExplorer
5-With myIE
6- '.Visible = True
7- .navigate "https:example.com"
8-Call CheckREadyState(myIE, 1)
9- .doucment.all("username")="ABC"
10-.doucment.all("password")="33443"
11-.doucment.all(login).click
12-Call CheckREadyState(myIE, 1)
13-'Sleep(3000)
Function CheckReadystate(ByRef myIE As Object, state1 As Integer)
With myIE
Do Until Not .Busy And .readyState = READYSTATE_COMPLETE
Debug.Print state1
Debug.Print .Busy
Debug.Print .readyState
DoEvents
Loop
End With
End Function
@duncan,
Your still using TWO internet objects you should remove one of the references as your openeing two instances of IE although you can only see one instance another one is created hidden. You don't need the latebound call if your adding the reference. Remember use one or the other or reference the instance without using the New operator.
Dim myIE As SHDocVw.InternetExplorerSet myIE = New InternetExplorer' Wait for the page to load. Do While IE.Busy Or IE.ReadyState <> 4 DoEvents Loop
1:2:3:4:5:6:7:
@duncan,
Your still using TWO internet objects you should remove one of the references as your openeing two instances of IE although you can only see one instance another one is created hidden. You don't need the latebound call if your adding the reference. Remember use one or the other or reference the instance without using the New operator.
Dim myIE As SHDocVw.InternetExplorerSet myIE = New InternetExplorer' Wait for the page to load. Do While IE.Busy Or IE.ReadyState <> 4 DoEvents Loop
1:2:3:4:5:6:7:
@duncan,
Your still using TWO internet objects you should remove one of the references as your openeing two instances of IE although you can only see one instance another one is created hidden. You don't need the latebound call if your adding the reference. Remember use one or the other or reference the instance without using the New operator.
Dim myIE As SHDocVw.InternetExplorerSet myIE = New InternetExplorer' Wait for the page to load. Do While IE.Busy Or IE.ReadyState <> 4 DoEvents Loop
1:2:3:4:5:6:7:
@duncan,
Your still using TWO internet objects you should remove one of the references as your openeing two instances of IE although you can only see one instance another one is created hidden. You don't need the latebound call if your adding the reference. Remember use one or the other or reference the instance without using the New operator.
Dim myIE As SHDocVw.InternetExplorerSet myIE = New InternetExplorer' Wait for the page to load. Do While IE.Busy Or IE.ReadyState <> 4 DoEvents Loop
1:2:3:4:5:6:7:
@duncan,
Your still using TWO internet objects you should remove one of the references as your openeing two instances of IE although you can only see one instance another one is created hidden. You don't need the latebound call if your adding the reference. Remember use one or the other or reference the instance without using the New operator.
Dim myIE As SHDocVw.InternetExplorerSet myIE = New InternetExplorer' Wait for the page to load. Do While IE.Busy Or IE.ReadyState <> 4 DoEvents Loop
1:2:3:4:5:6:7:
@duncan,
Your still using TWO internet objects you should remove one of the references as your openeing two instances of IE although you can only see one instance another one is created hidden. You don't need the latebound call if your adding the reference. Remember use one or the other or reference the instance without using the New operator.
Dim myIE As SHDocVw.InternetExplorerSet myIE = New InternetExplorer' Wait for the page to load. Do While IE.Busy Or IE.ReadyState <> 4 DoEvents Loop
1:2:3:4:5:6:7: