automate excel to login web pages

A

Ana

Hi,

I would like to know if anyone has a solution to log in into a web page that
requires a user name and a password from a macro.
I tried diferent codes from internet without any result

Is it possible to do it with a web query ?
I have just need to log to
https://www.bernstein.com/Reports/Summary.aspx?nid=108&relid=94565692

and then copy a table with values

Is it posible to copy the values from a table form i.explorer to excel or
shall I save the page first and then open it with excel?

any ideas?

thanks
 
D

Dan R.

Try this:

Sub test()
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "https://www.bernstein.com/login.aspx?ReturnUrl=" & _
"%2fReports%2fSummary.aspx%3fnid%" & _
"3d108%26relid%3d94565692&nid=108&relid=94565692"
Do Until .ReadyState = 4
DoEvents
Loop
Set ipf = .Document.all.Item("UserName")
ipf.Value = "username"
Set ipf = .Document.all.Item("Password")
ipf.Value = "password"
SendKeys "{ENTER}", True
End With
End Sub
 
A

Ana

Thanks for your help I tried your code , I am able to open de page, write the
user and the password but nothing else. It does not log in with the
information.

That is the same problem with all the code I tried I am not able to " clic
in the log in button "

Any idea?
thanks again
 
A

Ana

Thanks for your help,

I tried your but I still have the same problem I can open de page, write the
user and the password but nothing else. I can not log in.

SendKeys "{ENTER}", True

does not work for me but If I do it manually on the page it works with enter

any suggestions?

thanks again


Any idea?
thanks again
 
D

Dan R.

Try this one:

Sub test()
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "https://www.bernstein.com/login.aspx?ReturnUrl=" & _
"%2fReports%2fSummary.aspx%3fnid%" & _
"3d108%26relid%3d94565692&nid=108&relid=94565692"
Do Until .ReadyState = 4
DoEvents
Loop
Set ipf = .Document.all.Item("UserName")
ipf.Value = "username"
Set ipf = .Document.all.Item("Password")
ipf.Value = "password"
Set ipf = .Document.all.Item("LoginButton")
Do Until .ReadyState = 4
DoEvents
Loop
ipf.Click
End With
End Sub
 
J

JP

Using the sample code from my site, it would be

Set ElementCol = appIE.Document.getElementsByTagName("INPUT")

For Each btnInput In ElementCol
If btnInput.Id = "LoginButton" Then
btnInput.Click
Exit For
End If
Next btnInput

And I believe the code in Dan's last post would work as well.

--JP
 
A

avardaneg

Guys,

I'm trying to do something similar to what Ana was trying to do, the only
difference is that when I go to access the secured website I need, I need to
fill out the user id and password in a separate window that pops up... Any
suggestions on how I can tweak your pieces of code in order to fill out the
id & pwd in this separate window instead of the main window?

Thanks.
 
J

JP

If it's one of those modeless/emnuless dialog boxes, you probably
won't be able to use these techniques to access that website.

--JP
 
A

avardaneg

I see...
How about if I use "SendKeys" to send the ID+PWD information to the dialog
box?
Would that work?
 
J

JP

Oops I misspelled "menuless" LOL

Sendkeys might work, but it's not ideal. You probably want to bake
some "Application.Wait" calls to make sure the dialog box is fully
loaded before using that option.

i.e.

Application.Wait Now + TimeValue("00:00:01")

to add one second to the macro processing time.

Also you probably want to add some code that checks to make sure the
sendkeys was successful (i.e. look for an element on the next page
that would only appear if you actually made it to the next page).

--JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top