![]() |
Bienvenue invité ( Connexion | Inscription )
![]() |
![]()
Message
#1
|
|
![]() Macbidouilleur de bronze ! ![]() ![]() Groupe : Membres Messages : 391 Inscrit : 2 Jun 2006 Membre no 62 332 ![]() |
Hello tout le monde,
J'ai trouvé une fonction en vba sur le net qui calcule grâce à Google Maps la distance entre deux villes. Mais, elle requiert Microsoft XML v6.0 qui ne peut pas être installé sur un Mac. Voici la fonction : Code Function G_DISTANCE(Origin As String, Destination As String) As Double ' Requires a reference to Microsoft XML, v6.0 ' Draws on the stackoverflow answer at bit.ly/parseXML Dim myRequest As XMLHTTP60 Dim myDomDoc As DOMDocument60 Dim distanceNode As IXMLDOMNode G_DISTANCE = 0 ' Check and clean inputs On Error GoTo exitRoute Origin = WorksheetFunction.EncodeURL(Origin) Destination = WorksheetFunction.EncodeURL(Destination) ' Read the XML data from the Google Maps API Set myRequest = New XMLHTTP60 myRequest.Open "GET", "http://maps.googleapis.com/maps/api/directions/xml?origin=" _ & Origin & "&destination=" & Destination & "&sensor=false", False myRequest.send ' Make the XML readable usign XPath Set myDomDoc = New DOMDocument60 myDomDoc.LoadXML myRequest.responseText ' Get the distance node value Set distanceNode = myDomDoc.SelectSingleNode("//leg/distance/value") If Not distanceNode Is Nothing Then G_DISTANCE = distanceNode.Text / 1000 exitRoute: ' Tidy up Set distanceNode = Nothing Set myDomDoc = Nothing Set myRequest = Nothing End Function Est-ce que l'un d'entre vous, doué en vba, pourrait convertir cette fonction pour qu'elle tourne sous excel Mac (office 2011 ou 2016) ? Merci d'avance. m00n -------------------- MacBook Pro (15-inch, Late 2016), 2,9 GHz Intel Core i7, 16 Go 2133 MHz LPDDR3
|
|
|
![]() ![]() |
Nous sommes le : 5th July 2025 - 16:57 |