Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 23rd, 2007, 09:15 PM
magmike
Guest
 
Posts: n/a
Default Doing maps and hyperlinks

I'd like to set up an event procedure that when the city field is
double clicked they are sped away to a google map showing directions
and distance from our city (nashville) to the client city. The link is
as follows, but I can't figure out how to implement it:

http://maps.google.com/maps?f=d&hl=e...lle,+TN&daddr=[City],+[State]&sll=36.047349,-86.716609&sspn=0.0072,0.014462&ie=UTF8&z=9&om=1

Thanks for your help!

  #2  
Old August 23rd, 2007, 09:35 PM
Karl
Guest
 
Posts: n/a
Default Re: Doing maps and hyperlinks

use Application.FollowHyperlink


"magmike" <magmike7@yahoo.comwrote in message
news:1187899791.528364.136610@r23g2000prd.googlegr oups.com...
Quote:
I'd like to set up an event procedure that when the city field is
double clicked they are sped away to a google map showing directions
and distance from our city (nashville) to the client city. The link is
as follows, but I can't figure out how to implement it:
>
http://maps.google.com/maps?f=d&hl=e...lle,+TN&daddr=[City],+[State]&sll=36.047349,-86.716609&sspn=0.0072,0.014462&ie=UTF8&z=9&om=1
>
Thanks for your help!
>

  #3  
Old August 23rd, 2007, 10:15 PM
magmike
Guest
 
Posts: n/a
Default Re: Doing maps and hyperlinks

On Aug 23, 3:27 pm, "Karl" <some...@sbcglobal.bizwrote:
Quote:
use Application.FollowHyperlink
>
"magmike" <magmi...@yahoo.comwrote in message
>
news:1187899791.528364.136610@r23g2000prd.googlegr oups.com...
>
>
>
Quote:
I'd like to set up an event procedure that when the city field is
double clicked they are sped away to a google map showing directions
and distance from our city (nashville) to the client city. The link is
as follows, but I can't figure out how to implement it:
>
Quote:
http://maps.google.com/maps?f=d&hl=e...shville,+TN&da...[City],+[State]&sll=36.047349,-86.716609&sspn=0.0072,0.014462&ie=UTF8&z=9&o*m=1
>
Quote:
Thanks for your help!- Hide quoted text -
>
- Show quoted text -
That was easy. Thanks!

  #4  
Old August 23rd, 2007, 10:15 PM
Salad
Guest
 
Posts: n/a
Default Re: Doing maps and hyperlinks

magmike wrote:
Quote:
I'd like to set up an event procedure that when the city field is
double clicked they are sped away to a google map showing directions
and distance from our city (nashville) to the client city. The link is
as follows, but I can't figure out how to implement it:
>
http://maps.google.com/maps?f=d&hl=e...lle,+TN&daddr=[City],+[State]&sll=36.047349,-86.716609&sspn=0.0072,0.014462&ie=UTF8&z=9&om=1
>
Thanks for your help!
>
From a post a year or two ago I read in this group I came up with this
method. I pass to MakeUrl the arguments "Map" or "Driving". If "Map",
it creates just the map of the FROM address, if driving it has the
directions for the FROM to TO addresses.

I have a form with a "FROM" Address, city, state, zip as well as the
same for the TO fields. Press the command button to present the values.

I also added a command button to swap the From/To values on the form
even tho I could have passed an argument in the URL to present reverse
directions.

I do require both city and state in the form. I really don't care about
the zip but you can mod the code to whatever. Beyond that, if you have
a form with from/to fields using the field names in the routine then
this code should run without a hitch.

Private Sub MakeURL(strType As String)
On Error GoTo Err_MakeURL
Dim strURL As String
Dim objBrowser As Object

If IsNull(Me.City) Or IsNull(Me.State) Then
MsgBox "You need to supply at least the city and state.", ,
"Missing Info"
Me.City.SetFocus
ElseIf strType = "Driving" And (IsNull(Me.ToCity) Or
IsNull(Me.ToState)) Then
MsgBox "You need to supply at least eding city and state for
driving directions.", , "Missing Info"
Me.ToCity.SetFocus
Else
'Declare variables.

strURL = CreateUrl(Me.Address, Me.City, Me.State, Me.ZipCode)
If strType = "Driving" Then
strURL = strURL & "+" & "to" & "+" &
CreateUrl(Me.ToAddress, Me.ToCity, Me.ToState, Me.ToZipCode)
End If
strURL = "http://maps.google.com/maps?q=" & strURL &
"&iwloc=A&hl=en"

Dim obj As Object
Set obj = CreateObject("InternetExplorer.Application")
With obj
.Navigate2 strURL
.Visible = True
End With
Set obj = Nothing
End If
Exit_MakeURL:
Exit Sub

Err_MakeURL:
MsgBox Err.Description
Resume Exit_MakeURL

End Sub
Private Function CreateUrl(strAddress As Variant, strCity As String,
strState As String, strZip As Variant) As String
'generate the URL to pass to Google in browser.
Dim strURL As String
Dim strOrig As String
Dim intPos As Integer

If Not IsNull(strAddress) Then
strOrig = strAddress
Do While True
If strOrig <"" Then
intPos = InStr(strOrig, " ")
If intPos 0 Then
strURL = strURL & Left(strOrig, intPos - 1) & "+"
strOrig = LTrim(Mid(strOrig, intPos + 1))
Else
strURL = strURL & strOrig & "+"
Exit Do
End If
Else
Exit Do
End If
Loop
End If
strURL = strURL & strCity & "+" & strState & "+"
If Not IsNull(strZip) Then strURL = strURL & strZip & "+"

CreateUrl = Left(strURL, Len(strURL) - 1)

End Function
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles