sub to get post code to post code mileage from web site

A

Atishoo

I am using the sub below to retrieve the distance travelled between two UK
post codes, the sub inserts the post codes and triggers the calculate button
on the web site fine, but the last part of the sub to retrieve the post code
from the results table is way off the mark and the more I fiddle with it the
more I make a holy pigs ear of it!

any ideas?


Private Sub CommandButton1_Click()

Postcode = InputBox("Enter PostCode: ")

Postcode2 = InputBox("Enter 2nd PostCode: ")


Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL =
"http://www.postcode.org.uk/country/uk/_postcode-distance-calculator.asp"
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 Postcodebox = inputform.Item(0)
Postcodebox.Value = Postcode

Set Postcodebox2 = inputform.Item(1)
Postcodebox2.Value = Postcode2

Set POSTCODEbutton = inputform.Item(2)
POSTCODEbutton.Click



Set Table = IE.document.getElementsByTagname("Table")
Set Table = Table.Item(0)

c = Table.Item(6)

With Worksheets("sheet1").Range("A1")
..Value = c.Value
End With

IE.Quit
End Sub
 
A

Atishoo

thanks for your reply
What title did you give your new posting so I can do a search on it?
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top