Asked by duncanb7
at 2024-07-21 05:52:46
Point:250 Replies:7 POST_ID:828360USER_ID:11059
Topic:
Visual Basic Programming;Miscellaneous Programming;JavaScript
When I navigate the bank login website page by VBA with .navigate, and I found there is
no any element ID or type for username and password in the source code of html. It is
javascript function to let user to access the login page. So I need to use sendkey("myloginname")
instead of .document.all("username")="myloginname" to enter my login name in the webpage . The problem is when I run the sendkey("myloginname") in VBA, the "myloginname" is pasted on my VBA code not the location of the login box of the login page I navigate. How Can I control my cursor and move it to the bank page and exact login box?
I tried the sendkey() before, sometimes, it works but sometime it doesn't work as I said above.
it seems it is related to cursor position issue ?
Please veiw the following code espeically with Bold type for the sendkey which will send the
myloginname inside of my banklogin() code.
Please advise
Thanks
My code is here :
-------------------
Sub Banklogin()
Dim myIE As SHDocVw.InternetExplorer
Set myIE = Nothing
Set myIE = CreateObject("InternetExplorer.Application")
.navigate "www.mybank.com"
call waiting
sendkey ("myloginname")
myloginname.document.links(6).click 'enter the next page of login
End Sub
Function WAITING(ByRef myIE As SHDocVw.InternetExplorer)
With myIE
Do Until Not .Busy And .readyState = READYSTATE_COMPLETE
Loop
End With
End Function
no any element ID or type for username and password in the source code of html. It is
javascript function to let user to access the login page. So I need to use sendkey("myloginname")
instead of .document.all("username")="myloginname" to enter my login name in the webpage . The problem is when I run the sendkey("myloginname") in VBA, the "myloginname" is pasted on my VBA code not the location of the login box of the login page I navigate. How Can I control my cursor and move it to the bank page and exact login box?
I tried the sendkey() before, sometimes, it works but sometime it doesn't work as I said above.
it seems it is related to cursor position issue ?
Please veiw the following code espeically with Bold type for the sendkey which will send the
myloginname inside of my banklogin() code.
Please advise
Thanks
My code is here :
-------------------
Sub Banklogin()
Dim myIE As SHDocVw.InternetExplorer
Set myIE = Nothing
Set myIE = CreateObject("InternetExplorer.Application")
.navigate "www.mybank.com"
call waiting
sendkey ("myloginname")
myloginname.document.links(6).click 'enter the next page of login
End Sub
Function WAITING(ByRef myIE As SHDocVw.InternetExplorer)
With myIE
Do Until Not .Busy And .readyState = READYSTATE_COMPLETE
Loop
End With
End Function