Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Getting Web page contents not working sometimes

  Asked By: Clifton    Date: Feb 07    Category: MS Office    Views: 750
  

I have created macro which gets contents of web site then writes to file,
sometimes its doesnt work as expected.

Sub Test()
Dim ie As Object

'Create an object to Internet Explorer
Set ie = CreateObject("InternetExplorer.Application")

path1 = "http://money.rediff.com/money/jsp/markets_home.jsp"

ie.Visible = False
ie.Navigate (path1)

'Wait till explorer navigate's to the page
While (ie.Busy = True)
Wend
'MsgBox ("Hello")
'All the text on the current window will be assigned to strdata variable
'strdata = ie.Document.getElementByID("mkt_top_index").innerText
'strdata = ie.Document.body.getElementsByTagName
("div")(1).getElementsByTagName("table")(0).innerHTML
strdata = ie.Document.getElementById
("area02").getElementsByTagName("div")(0).getElementsByTagName("table")(0).getEl\
ementsByTagName("table")(0).getElementsByTagName("table")(1).innerText
ActiveCell.FormulaR1C1 = strdata
ActiveWorkbook.SaveAs Filename:="C:\ExcelFile.txt", _
FileFormat:=xlText, CreateBackup:=False
'MsgBox (strdata)
End Sub

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Getting Web page contents not working sometimes Or get search suggestion and latest updates.




Tagged: