Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default web query for driving directions

From a userform, I want the user to enter a "Start" address, and an "End"
address. Then a command button runs a web query, which fills different
textboxes; one with the directions, one with total miles, and another with
total travel time.

I don't necessarily have a preference with what website is queried. I am
currently calculating the miles between two zip codes using the longitude and
latitudes, but I think a webquery with directions will be nicer.

thank you,
Steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default web query for driving directions

Which part are you having a problem with?

Tim

"steve" wrote in message
...
From a userform, I want the user to enter a "Start" address, and an "End"
address. Then a command button runs a web query, which fills different
textboxes; one with the directions, one with total miles, and another with
total travel time.

I don't necessarily have a preference with what website is queried. I am
currently calculating the miles between two zip codes using the longitude
and
latitudes, but I think a webquery with directions will be nicer.

thank you,
Steve



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default web query for driving directions

I'm using google maps, and I was having trouble determining which tables to
select. Here's the code I came up with, which seems to be working but I'm
not confident with it. Any advice you could offer would be great. For
example, a better way to check if the user entered an invalid address. Also,
how to deal with the workbook name that gets automatically assigned. How can
I re-use the same name, rather than add a new one each time?

ThisWorkbook.Worksheets("Report").Activate
ThisWorkbook.Worksheets("Report").Cells.Clear

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://maps.google.com/maps?hl=en&output=html&f=d&saddr=" &
frmWizard.tbZipCode1.Value & "&daddr=" & frmWizard.tbZipCode2.Value &
"&btnG=Get+Directions" _
, Destination:=ThisWorkbook.Worksheets("Report").Ran ge("A1"))

'.Name = "DrivingDirections"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells 'xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
'.WebSelectionType = xlEntirePage 'xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "9,10"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With


'pull out the miles from "B1"
Dim Miles As Variant
Dim x As String

x = ThisWorkbook.Worksheets("Report").Range("B1")
Miles = Split(x, " ")
If x < "" Then
frmWizard.tbTotalDistance = Miles(0)
Else
frmWizard.tbTotalDistance = "Invalid Zip Code"
End If







"Tim Williams" wrote:

Which part are you having a problem with?

Tim

"steve" wrote in message
...
From a userform, I want the user to enter a "Start" address, and an "End"
address. Then a command button runs a web query, which fills different
textboxes; one with the directions, one with total miles, and another with
total travel time.

I don't necessarily have a preference with what website is queried. I am
currently calculating the miles between two zip codes using the longitude
and
latitudes, but I think a webquery with directions will be nicer.

thank you,
Steve




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
Can you freeze in two directions in excel Amber Excel Discussion (Misc queries) 3 May 13th 10 06:54 PM
Looking up and create driving directions JackR Excel Discussion (Misc queries) 2 February 1st 09 04:53 PM
V/HLOOKUP in both directions? thexdane Excel Worksheet Functions 5 November 15th 07 03:31 PM
Lookup 2 directions Tony Excel Worksheet Functions 1 March 28th 06 04:12 AM
last row query (thats driving me mad!) jaimetimbrell Excel Programming 14 February 8th 06 10:20 PM


All times are GMT +1. The time now is 11:46 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"