Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi have been using a dump routine posted by Joel to ascertain the reference
for objects in several web pages including three for mileage calculation. Am unable to return the mileage by road output from the following web page, URL = "http://www.freemaptools.com/distance-between-uk-postcodes.htm" am sure the reference is : Set dis = IE.document.getElementsByTagname("INPUT") Set distance = dis.Item(7) Worksheets("sheet1").Range("a1") = distance.innertext but get no value returned from this! Should I be using a different suffix other than "innertext"? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This should work. I used the code I worked on a couple of weeks ago
Private Sub CommandButton1_Click() Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True For Each c In Worksheets("Sheet1").Range("D6:N6").Cells If c.Offset(0, 1).Value < "" Then URL = "http://www.freemaptools.com/distance-between-uk-postcodes.htm" IE.Navigate2 URL Do While IE.readyState < 4 Or _ IE.busy = True DoEvents Loop Set Form = IE.document.getElementsByTagname("Form") 'Call Dump(IE) Set inputform = Form.Item(0) Set Postcodebox1 = inputform.Item(0) Postcodebox1.Value = c.Value Set Postcodebox2 = inputform.Item(1) Postcodebox2.Value = c.Offset(0, 1).Value Set POSTCODEbutton = inputform.Item(2) POSTCODEbutton.Click Do While IE.readyState < 4 Or _ IE.busy = True DoEvents Loop 'Call Dump(IE) Set Table = IE.document.getElementsByTagname("table") Set Distance = IE.document.getElementById("distance") MsgBox ("Distance : " & Distance.Value) Set Transport = IE.document.getElementById("transport") MsgBox ("Transport : " & Transport.Value) Next IE.Quit End Sub Sub Dump(IE) With Sheets("Dump") ..Cells.ClearContents RowCount = 1 For Each itm In IE.document.all ..Range("A" & RowCount) = itm.Tagname ..Range("B" & RowCount) = itm.classname ..Range("C" & RowCount) = itm.ID ..Range("D" & RowCount) = Left(itm.innertext, 1024) RowCount = RowCount + 1 Next itm End With End Sub "Atishoo" wrote: Hi have been using a dump routine posted by Joel to ascertain the reference for objects in several web pages including three for mileage calculation. Am unable to return the mileage by road output from the following web page, URL = "http://www.freemaptools.com/distance-between-uk-postcodes.htm" am sure the reference is : Set dis = IE.document.getElementsByTagname("INPUT") Set distance = dis.Item(7) Worksheets("sheet1").Range("a1") = distance.innertext but get no value returned from this! Should I be using a different suffix other than "innertext"? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Cheers Joel.
i did try .value on that scrap of code i attatched to the question but it returned an error everytime but yours works fine! Think its down to basic bad programming on my part! ta "Joel" wrote: This should work. I used the code I worked on a couple of weeks ago Private Sub CommandButton1_Click() Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True For Each c In Worksheets("Sheet1").Range("D6:N6").Cells If c.Offset(0, 1).Value < "" Then URL = "http://www.freemaptools.com/distance-between-uk-postcodes.htm" IE.Navigate2 URL Do While IE.readyState < 4 Or _ IE.busy = True DoEvents Loop Set Form = IE.document.getElementsByTagname("Form") 'Call Dump(IE) Set inputform = Form.Item(0) Set Postcodebox1 = inputform.Item(0) Postcodebox1.Value = c.Value Set Postcodebox2 = inputform.Item(1) Postcodebox2.Value = c.Offset(0, 1).Value Set POSTCODEbutton = inputform.Item(2) POSTCODEbutton.Click Do While IE.readyState < 4 Or _ IE.busy = True DoEvents Loop 'Call Dump(IE) Set Table = IE.document.getElementsByTagname("table") Set Distance = IE.document.getElementById("distance") MsgBox ("Distance : " & Distance.Value) Set Transport = IE.document.getElementById("transport") MsgBox ("Transport : " & Transport.Value) Next IE.Quit End Sub Sub Dump(IE) With Sheets("Dump") .Cells.ClearContents RowCount = 1 For Each itm In IE.document.all .Range("A" & RowCount) = itm.Tagname .Range("B" & RowCount) = itm.classname .Range("C" & RowCount) = itm.ID .Range("D" & RowCount) = Left(itm.innertext, 1024) RowCount = RowCount + 1 Next itm End With End Sub "Atishoo" wrote: Hi have been using a dump routine posted by Joel to ascertain the reference for objects in several web pages including three for mileage calculation. Am unable to return the mileage by road output from the following web page, URL = "http://www.freemaptools.com/distance-between-uk-postcodes.htm" am sure the reference is : Set dis = IE.document.getElementsByTagname("INPUT") Set distance = dis.Item(7) Worksheets("sheet1").Range("a1") = distance.innertext but get no value returned from this! Should I be using a different suffix other than "innertext"? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
AAAArrrggghhhhh
Why aint this working??? Am just getting empty values ?? Private Sub CommandButton1_Click() For Each c In Worksheets("Sheet1").Range("pcrange3").Cells If c.Offset(0, 1).Value < "" Then Set IE = CreateObject("InternetExplorer.Application") IE.Visible = False URL = "http://www.freemaptools.com/distance-between-uk-postcodes.htm" IE.Navigate2 URL Do While IE.readyState < 4 DoEvents Loop Do While IE.busy = True DoEvents Loop Set Form = IE.document.getElementsByTagname("Form") Set inputform = Form.Item(0) Set Postcodebox1 = inputform.Item(0) Postcodebox1.Value = c.Value Set Postcodebox2 = inputform.Item(1) Postcodebox2.Value = c.Offset(0, 1).Value Set POSTCODEbutton = inputform.Item(2) POSTCODEbutton.Click Do While IE.busy = True Loop Set Transport = IE.document.getElementById("transport") c.Offset(0, 1) = Transport.Value IE.Quit End If Next End Sub "Atishoo" wrote: Cheers Joel. i did try .value on that scrap of code i attatched to the question but it returned an error everytime but yours works fine! Think its down to basic bad programming on my part! ta "Joel" wrote: This should work. I used the code I worked on a couple of weeks ago Private Sub CommandButton1_Click() Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True For Each c In Worksheets("Sheet1").Range("D6:N6").Cells If c.Offset(0, 1).Value < "" Then URL = "http://www.freemaptools.com/distance-between-uk-postcodes.htm" IE.Navigate2 URL Do While IE.readyState < 4 Or _ IE.busy = True DoEvents Loop Set Form = IE.document.getElementsByTagname("Form") 'Call Dump(IE) Set inputform = Form.Item(0) Set Postcodebox1 = inputform.Item(0) Postcodebox1.Value = c.Value Set Postcodebox2 = inputform.Item(1) Postcodebox2.Value = c.Offset(0, 1).Value Set POSTCODEbutton = inputform.Item(2) POSTCODEbutton.Click Do While IE.readyState < 4 Or _ IE.busy = True DoEvents Loop 'Call Dump(IE) Set Table = IE.document.getElementsByTagname("table") Set Distance = IE.document.getElementById("distance") MsgBox ("Distance : " & Distance.Value) Set Transport = IE.document.getElementById("transport") MsgBox ("Transport : " & Transport.Value) Next IE.Quit End Sub Sub Dump(IE) With Sheets("Dump") .Cells.ClearContents RowCount = 1 For Each itm In IE.document.all .Range("A" & RowCount) = itm.Tagname .Range("B" & RowCount) = itm.classname .Range("C" & RowCount) = itm.ID .Range("D" & RowCount) = Left(itm.innertext, 1024) RowCount = RowCount + 1 Next itm End With End Sub "Atishoo" wrote: Hi have been using a dump routine posted by Joel to ascertain the reference for objects in several web pages including three for mileage calculation. Am unable to return the mileage by road output from the following web page, URL = "http://www.freemaptools.com/distance-between-uk-postcodes.htm" am sure the reference is : Set dis = IE.document.getElementsByTagname("INPUT") Set distance = dis.Item(7) Worksheets("sheet1").Range("a1") = distance.innertext but get no value returned from this! Should I be using a different suffix other than "innertext"? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Referencing two versions Object models | Excel Programming | |||
Referencing Object Names with Variable | Excel Programming | |||
Referencing worksheet CODENAME in a chart object. | Excel Programming | |||
Re referencing an object | Excel Programming | |||
Referencing a ComboBox control from a Workbook Object? | Excel Programming |