Nécessite des champs texte
txtRue
txtRue2
txtVille
txtVille2
txtCP
txtCP2
txtPays
txtPays2
+ activer les références microsoft internet controls et microsoft html object library
et faire dans un private sub : Call viaGoogleIti(Me!txtRue, Me!txtVille, Me!txtCP, Me!txtPays, Me!txtRue2, Me!txtVille2, Me!txtCP2, Me!txtPays2)
--------------------------------------------------------------------------
Sub viaGoogleIti(strDireccion, strVille, strCP, strfr, strDireccion2, strVille2, strCP2, strfr2 As String)
Dim strURL As String
Dim IE As New InternetExplorer
Dim StrBody As String
Dim Borne_Debut As Long
Dim Borne_Fin As Long
Dim IE_Doc As HTMLDocument
strDireccion = Replace(strDireccion, " ", "+") 'Convertir Espace a +
strDireccion = Replace(strDireccion, ",", "+") 'Convertir , a +
strDireccion = Replace(strDireccion, "-", "+") 'Convertir , a +
strDireccion2 = Replace(strDireccion2, " ", "+") 'Convertir Espace a +
strDireccion2 = Replace(strDireccion2, ",", "+") 'Convertir , a +
strDireccion2 = Replace(strDireccion2, "-", "+") 'Convertir , a +
strVille = Replace(strVille, " ", "+")
strVille2 = Replace(strVille2, " ", "+")
strVille = Replace(strVille, "-", "+")
strVille2 = Replace(strVille2, "-", "+")
strURL = "http://www.google.com/maps?"
strURL = strURL & "hl=fr&saddr=" & strDireccion & "+"
strURL = strURL & strVille & "+"
strURL = strURL & strCP
strURL = strURL & "," & strfr
strURL = strURL & "&daddr=" & strDireccion2 & "+"
strURL = strURL & strVille2 & "+"
strURL = strURL & strCP2
strURL = strURL & "," & strfr2
Me.txtDirection = strURL 'Pour passer par le Navigateur Web Microsoft
IE.Navigate strURL, openInTab
AttenteIE IE
''rendre la page visible
IE.Visible = True
Set IE_Doc = IE.Document
StrBody = IE_Doc.body.innerHTML
Borne_Debut = InStr(1, StrBody, "altroute-rcol altroute-info""> <span>") + 36
Borne_Fin = InStr(Borne_Debut, StrBody, "</span>")
' MsgBox Mid(StrBody, Borne_Debut, Borne_Fin - Borne_Debut)
Me.nombredekm = Mid(StrBody, Borne_Debut, Borne_Fin - Borne_Debut)
IE.Quit
End Sub