View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Pete_UK Pete_UK is offline
external usenet poster
 
Posts: 8,856
Default Logging onto a website

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

On Dec 11, 8:13*pm, joel wrote:
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

--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=161675

Microsoft Office Help