Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Web to Excel Using VBA

  Asked By: Can    Date: Oct 13    Category: MS Office    Views: 1262
  

I am trying to access a web page which uses POST method. Once I enter into the
site, the user has to provide the Login and Password. Once it goes to the main
page , am trying to copy the entire content into excel using VBA.

Here is the scenario:
When I log into mail.yahoo.com, i have to provide the login name and password
then only the user can see their entire list of mails. I want the next page
which is displayed to be in an excel document.
Below is the code which I have tried, but I couldnot get the subsequent page.
In excel still the login page is getting copied.

Can some one help me in how to do this?

Public Sub IETest()
Dim intReadyState As Integer
Dim objie As Object
' Open up Internet Explorer
Set objie = CreateObject("InternetExplorer.Application")
objie.Visible = True
objIE.navigate "http://www.acces.com/access.asp"
Do While Not intReadyState = 4
intReadyState = objie.readystate
Loop
objie.Document.all("frm_userlogin").Value = "20228499"
objie.Document.all("frm_userpassword").Value = "easy06"
objie.Document.all.Item("Login").Click

workbooks.open "http://www.acces.com/access.asp"

End Sub

'the log in page and the content page are same in this case.

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Ujala Hashmi     Answered On: Oct 13

Try changing the line for the Login button from "Click" to "Submit". You should
be submitting the form data, not actually trying to click the button.

 
Answer #2    Answered By: Robin Bailey     Answered On: Oct 13

But, that doesn't work. I am able to log  in
succesfully and I can view the next page  when I use "Click" option but am not
able to get the exact data into the excel. When I try using "workbook.open", it
gives the initial login  page into excel  , but not the page with data.

Any other possible way ?

 
Answer #3    Answered By: Oscar Evans     Answered On: Oct 13

Don't you need to wait until the "Click" is resolved? I have a routine that
enters data on a page  multiple times, using a loop. Each time I do the
"Click", I have to wait until the next page is ready:

Set oForm = oIE.Document.forms(0)
For Each oCell In ActiveSheet.Range("A2:A500")
If oCell.Value = "" Then Exit For
.
.
.
oForm(".save2").Click
Do: DoEvents: Loop While oIE.Busy
Do: DoEvents: Loop Until oIE.ReadyState = READYSTATE_COMPLETE
Set oForm = oIE.Document.forms(0)
Next oCell

 
Answer #4    Answered By: Michael Evans     Answered On: Oct 13

I have tried, but could not succeed.

Can you please give me the entire  code, if you feel that this would help  me in
getting the result.

After logging into the page, I need the contents of the second page,
considering the login page  as 1st page.

 
Didn't find what you were looking for? Find more on Web to Excel Using VBA Or get search suggestion and latest updates.




Tagged: