Get Data From Website That Requires Log-in

auto

Board Regular
Joined
May 20, 2012
Messages
53
hi,
i am having truble with my macro maybe some1 can help me out,
i need to get data from a website that requires to log-in, so i set this Vba, and i get an error "object dosent support this property or method" can anyone help me with this?

Sub GetTable()

Dim IEApp As Object
Dim IEDoc As Object
Dim IETable As Object
Dim clip As DataObject

Set IEApp = New InternetExplorer

IEApp.Visible = True

IEApp.Navigate "http://www.sample.com/login.php"
Do While IEApp.Busy: DoEvents: Loop
Do Until IEApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop

Set IEDoc = IEApp.Document

With IEDoc.forms(0)
'HERE I GET THE ERROR "object dosent support this property Or method" '
.email_address.Value = "my user name"
.Password.Value = "my password"
.submit


did some1 has an idea where i am going wrong?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
hey ppl, i got the code running, but i need a timer should do it every morning at 9:00 am how can i do it?
here is my code;
Sub IE_Automation()
Dim i As Long
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
web = "http://www.sample.com/login.php" '<- Change to yuor address
' Create InternetExplorer Object
Set IE = CreateObject("InternetExplorer.Application")

' You can uncoment Next line To see form results
IE.Visible = True

' Send the form data To URL As POST binary request
IE.Navigate web

' Statusbar
Application.StatusBar = web & " is loading. Please wait..."

' Wait while IE loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

' Find 2 input tags:
' 1. Text field
'
'
' 2. Button
'

Application.StatusBar = "Search form submission. Please wait..."

Set objCollection = IE.Document.getElementsByTagName("input")

If web = "http://www.sample.com/login.php" Then
user = "sample" '<- user id for website 1


Else
user = Environ("USERNAME") '<- Otherwise default user id
End If

i = 0
While i < objCollection.Length

If objCollection(i).Name = "user" Then

' Set text for search
objCollection(i).Value = user

Else
'This is the password section uncomment and add in password
If objCollection(i).Type = "password" And _
objCollection(i).Name = "password" Then
objCollection(i).Value = "sample" '<-Your password here

Else
If objCollection(i).Name = "$txtUserName" Then '<- sometimes the fields are named funny (right click on the web page and view the source... then search for user name to get the fiel name to enter into here)
objCollection(i).Value = user
End If
End If
End If
i = i + 1
Wend
i = 0
'This section clicks on the lgin button for you (if it can find it)
While i < objCollection.Length
If objCollection(i).Name = "button" Then
Set objElement = objCollection(i)
objElement.Click ' click button to search
End If
i = i + 1
Wend


' Wait while IE re-loading...
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop

' Show IE
IE.Visible = True

' Clean up
Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing

Application.StatusBar = ""
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,828
Messages
6,168,484
Members
452,193
Latest member
Arlochorim

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