Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default referencing web site object

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default referencing web site object

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default referencing web site object

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default referencing web site object

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing two versions Object models Cory Excel Programming 4 February 9th 08 07:19 PM
Referencing Object Names with Variable jbl25[_8_] Excel Programming 1 August 26th 05 12:44 AM
Referencing worksheet CODENAME in a chart object. Bing Excel Programming 2 February 14th 05 07:08 PM
Re referencing an object rci Excel Programming 1 February 1st 04 04:49 AM
Referencing a ComboBox control from a Workbook Object? debartsa Excel Programming 3 December 9th 03 08:43 PM


All times are GMT +1. The time now is 06:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"