VBA can't fire onBlur event to insert password into IE

Ericng

New Member
Joined
Apr 26, 2021
Messages
1
Office Version
  1. 2010
Platform
  1. Windows
My VBA can't fire onBlur event when inserting password into IE.

My VBA code manged to open the target webpage in IE, locate the login page, activate the correct Tab, insert my own ID and password into and they appear as text in the correct input boxes. However when my VBA code clicks the Login Button, the password is not processed. Yet when I do the same (ie. insert ID and password via VBA) manually, then I use VBA to click the Login Button, the webpage processes my login correctly. When I checked the webpage, I see that it has a Blur Event which activates a "js(84)" function. It appears that my VBA is not firing the onBlur event. Please help.

My VBA codes are :

dim and set IE and navigate done, then :

"
IE.Document. getElementbyID("SpLoginIdPw-singpass-id").focus
IE.Document. getElementbyID("SpLoginIdPw-singpass-id").fireEvent onKeydown
IE.Document. getElementbyID("SpLoginIdPw-singpass-id").Value = "S12345678D"
IE.Document. getElementbyID("SpLoginIdPw-singpass-id").fireEvent onBlur

IE.Document. getElementbyID("SpLoginIdPw-password").focus
IE.Document. getElementbyID("SpLoginIdPw-password").fireEvent onKeydown
IE.Document. getElementbyID("SpLoginIdPw-password").Value = "*********"
IE.Document. getElementbyID("SpLoginIdPw-password").fireEvent onBlur

IE.Document. getElementbyID("SpLoginIdPw-login-button").focus
IE.Document. getElementbyID("SpLoginIdPw-login-button").click
"

The website is : https://saml.singpass.gov.sg/spservice/welcome
My VBA code clicks the "Password Login" tab before executing the above codes.

After I found the onBlur event would not fire, I changed to "dispatchEvent". I also tried the following :

"
Dim objC As Object

Set objC = IE.Document.createEvent "keyboardEvent"
objC.InitEvent onBlur, True, False
IE.Document. getElementbyID("SpLoginIdPw-singpass-id").fireEvent objC

Set objC = IE.Document.createEvent "keyboardEvent"
objC.InitEvent onBlur, True, False
IE.Document. getElementbyID("SpLoginIdPw-password").fireEvent objC"
"

Then followed by login-button. But all these don't work either.

Please help.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,214,972
Messages
6,122,530
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top