Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default sub to get post code to post code mileage from web site


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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default sub to get post code to post code mileage from web site


I couldn't post my reply so I took out a new posting

"Atishoo" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default sub to get post code to post code mileage from web site


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

"Joel" wrote:

I couldn't post my reply so I took out a new posting

"Atishoo" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 267
Default sub to get post code to post code mileage from web site


Its OK have found it! Notice stefi is interested too!
thanks for that fix ta john


"Joel" wrote:

I couldn't post my reply so I took out a new posting

"Atishoo" wrote:

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

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
post a thread via VBA code hesham New Users to Excel 0 December 4th 07 01:46 PM
Post Code Adam Excel Worksheet Functions 2 September 6th 07 04:12 PM
Post code lookup Paul Williams Excel Worksheet Functions 5 November 23rd 06 08:25 PM
Post code & Suburbs varun Excel Discussion (Misc queries) 1 June 2nd 05 04:21 AM


All times are GMT +1. The time now is 03:50 AM.

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

About Us

"It's about Microsoft Excel"