Ankitsingh
New Member
- Joined
- May 16, 2020
- Messages
- 1
- Office Version
- 2010
- Platform
- Windows
' HardCode Value, which is alreday define in the code like 4
Sub PullDatafromWeb()
Dim IE As Object
Dim doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "Google"
Do While IE.Busy Or IE.readyState <> 4
Application.Wait DateAdd("s", 1, Now)
Loop
Set doc = IE.document
doc.getElementsByClassName("gLFyf gsfi")(0).Value = 4
'IE.document.getElementByName("q")(0).Value = 4 'Always Take ID Value from Web Page
'IE.document.getElementById("num2").Value = 4 Or you can use below line after Setting doc Set doc = IE.document
'doc.getElementById("num2").Value = 3
SendKeys "{Enter}"
'doc.getElementsByTagName("div")(1).innerText
StrAdd = doc.getElementById("result-stats").innerText 'Error on this line
'doc.getElementById("resultstats").innerText
' If HTML Page does not have Id then we need to use Class Name
'along with Index,Index always get started with 0
'StrMult = doc.getElementsByClassName("clslbl")(2).innerText
ThisWorkbook.Sheets("Sheet1").Range("C2").Value = StrAdd
'ThisWorkbook.Sheets("Sheet1").Range("D2").Value = StrMult
End Sub
Sub PullDatafromWeb()
Dim IE As Object
Dim doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "Google"
Do While IE.Busy Or IE.readyState <> 4
Application.Wait DateAdd("s", 1, Now)
Loop
Set doc = IE.document
doc.getElementsByClassName("gLFyf gsfi")(0).Value = 4
'IE.document.getElementByName("q")(0).Value = 4 'Always Take ID Value from Web Page
'IE.document.getElementById("num2").Value = 4 Or you can use below line after Setting doc Set doc = IE.document
'doc.getElementById("num2").Value = 3
SendKeys "{Enter}"
'doc.getElementsByTagName("div")(1).innerText
StrAdd = doc.getElementById("result-stats").innerText 'Error on this line
'doc.getElementById("resultstats").innerText
' If HTML Page does not have Id then we need to use Class Name
'along with Index,Index always get started with 0
'StrMult = doc.getElementsByClassName("clslbl")(2).innerText
ThisWorkbook.Sheets("Sheet1").Range("C2").Value = StrAdd
'ThisWorkbook.Sheets("Sheet1").Range("D2").Value = StrMult
End Sub