Automatic Login in site using vba

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I need a help for login in one site.

My matter is that, in a different way respect my previous experiences, I cannot univocally identify the login and password fields.

For example, below you can see the framework of the login field, analysed seven times.


input id="lQ8g5" class="atbox" type="text" maxlength="22" value=""

input id="kR9g5" class="atbox" type="text" maxlength="22" value=""

input id="jSAg5" class="atbox" type="text" maxlength="22" value=""

input id="iTBg5" class="atbox" type="text" maxlength="22" value=""

input id="hA3g5" class="atbox" type="text" maxlength="22" value=""

input id="n30g5" class="atbox" type="text" maxlength="22" value=""

input id="yVAg5" class="atbox" type="text" maxlength="22" value=""


I'd like some suggestions, thank's.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Here's one way. If the login field is the first input element:

Code:
    IE.document.getElementsByTagName("INPUT")(0).Value = "your login id"
If it's the second input element change the (0) to (1), etc.
 
Upvote 0
Ok for login and password, thank you.

Code:
IE.document.getElementsByTagName("INPUT")(0).Value = "your login id"
IE.document.getElementsByTagName("INPUT")(1).Value = "your password"

Now I'm struggling with the button, but unsuccesfully.
It's the only button in the page.


Above two exemples:

button id="z472n" class="button5" type="button">Enter</button>

button id="z425p" class="button5" type="button">Enter</button>


My attempt (error 438):

Code:
IE.document.getElementsByTagName("button")(0).click
 
Last edited:
Upvote 0
What is error 438? Has the page completely loaded? Try it without the .Click, i.e. set it to an object variable to make sure the element exists before calling the Click method.
 
Upvote 0
It was something about the pointer position, but I don't understood exactly what.
Anyway, in the following way it works.

Code:
IE.document.getElementsByTagName("INPUT")(0).Value = myId
SendKeys "{Tab}", True
IE.document.getElementsByTagName("INPUT")(1).Value = myCode
SendKeys "{Tab}", True
IE.document.getElementsByTagName("button")(0).Click

Have you got idea what could it be?
 
Last edited:
Upvote 0
Some more details:
1 - the error 438 was linked to other steps, I solved it;
2 - without the SendKeys "{Tab}", True, the macro types correctly login and password, but the authentication fails with the following message: "please fill out all required fields", as login or password were not typed.
 
Upvote 0

Forum statistics

Threads
1,215,992
Messages
6,128,170
Members
449,429
Latest member
ianharper68

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