stethoscoop
New Member
- Joined
- Nov 13, 2015
- Messages
- 9
I wrote a piece of code to open a website and log in on the website.
I used different variantions of the code with the help of these two topics:
http://www.mrexcel.com/forum/<wbr>excel-questions/461524-visual-<wbr>basic-applications-open-<wbr>website-logon-username-<wbr>password-3.html
http://www.mrexcel.com/forum/<wbr>excel-questions/465434-web-<wbr>username-password-form-submit.<wbr>html#post2297790
no matter what i try, it won't work. The website opens, but the username/password is not filled in.
I will show you two variations of my multiple attempts:
My first attempt:
The problem with this code is that it automatically closes the website after loading.
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
When i delete this part. The website will stay open.
My final attempt:
This opens the website normally, but it does not fill in the 'code', 'username' and 'password'
A piece of the html: (i deleted the brackets in front of the html, it kept messing up the post)
form action="/v30/" method="post" style="margin:0px">
label for="gacode">code:
input id="gacode" name="gacode" placeholder="code" class="form-input-field" type="text" value="">
label for="code">gebruikersnaam:
input id="code" name="code" placeholder="gebruikersnaam" class="form-input-field" type="text" value="">
label for="access">wachtwoord:
input id="access" placeholder="wachtwoord" name="access" class="form-input-field" type="password" value="">
input type="submit" class="submit-button" value="inloggen">
input type="hidden" value="http://www.atosi.nl" name="return">
input type="hidden" value="M-95371" name="maat">
input type="hidden" name="doit" value="1">
/form
Does anybody know what im doing wrong?
Thanks in advance!
I used different variantions of the code with the help of these two topics:
http://www.mrexcel.com/forum/<wbr>excel-questions/461524-visual-<wbr>basic-applications-open-<wbr>website-logon-username-<wbr>password-3.html
http://www.mrexcel.com/forum/<wbr>excel-questions/465434-web-<wbr>username-password-form-submit.<wbr>html#post2297790
no matter what i try, it won't work. The website opens, but the username/password is not filled in.
I will show you two variations of my multiple attempts:
My first attempt:
Code:
Sub Test()
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
IE.navigate ("https://www.atosi.nl")
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
IE.Document.Forms(0).all("gacode").Value = "me"
IE.Document.Forms(0).all("code").Value = "mypasssword"
IE.Document.Forms(0).all("access").Value = "mypasssword"
IE.Document.Forms(0).submit
End Sub
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop
When i delete this part. The website will stay open.
My final attempt:
Code:
Sub Test2()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.application")
With IE
.Visible = True
.navigate ("www.atosi.nl")
While .Busy Or .readyState <> 4: DoEvents: Wend
.Document.getElementByID("form-input-field_gacode").Focus
.Document.getElementByID("gacode").Value = "code"
.Document.getElementByID("code").Focus
.Document.getElementByID("code").Value = "username"
.Document.getElementByID("access").Focus
.Document.getElementByID("access").Value = "Password"
.Document.all("submit").Click
While .Busy Or .readyState <> 4: DoEvents: Wend
Debug.Print .LocationUrl
End With
End Sub
A piece of the html: (i deleted the brackets in front of the html, it kept messing up the post)
form action="/v30/" method="post" style="margin:0px">
label for="gacode">code:
input id="gacode" name="gacode" placeholder="code" class="form-input-field" type="text" value="">
label for="code">gebruikersnaam:
input id="code" name="code" placeholder="gebruikersnaam" class="form-input-field" type="text" value="">
label for="access">wachtwoord:
input id="access" placeholder="wachtwoord" name="access" class="form-input-field" type="password" value="">
input type="submit" class="submit-button" value="inloggen">
input type="hidden" value="http://www.atosi.nl" name="return">
input type="hidden" value="M-95371" name="maat">
input type="hidden" name="doit" value="1">
/form
Does anybody know what im doing wrong?
Thanks in advance!