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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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