Logging onto a website

P

Pete_UK

Is it possible in a macro to go to a website (URL in say A1) and to
pass parameters like login name (in A2) and password (in A3), so that
you could automatically log in to that website? If so, is it then
possible to simulate mouse-clicks on subsequent pages, so that you
could choose from options to get further into the site? Option choices
could be listed in A4, A5 etc. so I could set this up for a variety of
clients.

Ultimately, what I would like to do is to print off a page (which
might be an HTML page, but is sometimes shown in a PDF viewer)
automatically. The page is a copy invoice for my client(s), and
currently I have to log on to the supplier's website, then maybe
select the client from a list, maybe select "View Invoices" from
another list, and ultimately select the appropriate invoice from
another list (usually in reverse date order). All of this takes a
considerable amount of time just to get a paper copy (which used to be
mailed to me, but suppliers now seem to prefer to give you web access
to the invoices), so I'd be grateful if I can speed this process up.

Pete
 
J

joel

It is possible, I have done it lotes of times. In one case I went t
over 2200 webpages and collected the data onto a single spreadsheet.
you give me the URL (not the password nor user account) I can gert yo
started
 
J

joel

Below is the login for the N Power Website. Change the UserName and
Password as required. It took me a long time to learn all the ticks of
downloading webpages into excel. If you do a google search for the
string below you will find lots of my examples from Microsoft and
TheCodeCage Postings.

Joel Excel VBA IE



Sub NPowerLogin()

MyUserName = "UserName"
MyPassword = "Password"

URL = "https://business.npower.com/myaccount/login.aspx"

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True


'get web page
IE.Navigate2 URL
Do While IE.readystate <> 4 Or _
IE.busy = True

DoEvents
Loop

Set UserName = IE.document.getelementbyid("txtUsername")

'check if already login, Username object wouldn't exist if loggin
If Not UserName Is Nothing Then
UserName.Value = MyUserName
Set Password = IE.document.getelementbyid("txtPassword")
Password.Value = MyPassword

Set Form = IE.document.getelementsbytagname("Form")

Form(0).submit

'wait for login
Do While IE.readystate <> 4 Or _
IE.busy = True

DoEvents
Loop
MsgBox ("Logged In")
End If


IE.Quit
End Sub
 
P

Pete_UK

Thanks for that, Joel.

It's a bit too late to try it now, but I'll have a go tomorrow, as
well as searching for some of your other examples.

Cheers,

Pete
 

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