Hallo zusammen
Ich habe einen Excel VBA Code auf einem Windows PC, der auf einem MAC mit Excel 2011 einfach nicht läuft, wer kann mir da weiterhelfen, brauche dies unbedingt, vielen herzlichen Dank für Eure Hilfe! Die Excel-Funktion Entfernung() gibt die Kilometer-Distanz zwischen zwei Orten zurück. Dazu wird im Hintergrund eine Abfrage über google-Maps gemacht.
Hier der Code:
Public Function Entfernung _
( _
Start_Strasse As String, Start_Stadt_PLZ As String, _
Start_Bundesland As String, Start_Staat As String, _
Ziel_Strasse As String, Ziel_Stadt_PLZ As String, _
Ziel_Bundesland As String, Ziel_Staat As String _
)
Dim surl As String
Dim oXH As Object
Dim bodytxt As String
surl = "http://maps.googleapis.com/maps/api/distancematrix/xml?origins=" & _
Replace(Start_Strasse, " ", "+") & "+" & Replace(Start_Stadt_PLZ, " ", "+") & "+" & _
Replace(Start_Bundesland, " ", "+") & "+" & Replace(Start_Staat, " ", "+") & _
"&destinations=" & _
Replace(Ziel_Strasse, " ", "+") & "+" & Replace(Ziel_Stadt_PLZ, " ", "+") & "+" & _
Replace(Ziel_Bundesland, " ", "+") & "+" & Replace(Ziel_Staat, " ", "+") & _
"&mode=driving&sensor=false&units=metric"
Set oXH = CreateObject("WinHttp.WinHttpRequest.5.1")
With oXH
.Open "get", surl, False
.send
bodytxt = .responseText
End With
bodytxt = Right(bodytxt, Len(bodytxt) - InStr(1, bodytxt, "<value>") - 5)
bodytxt = Right(bodytxt, Len(bodytxt) - InStr(1, bodytxt, "<value>") - 6)
Entfernung = Left(bodytxt, InStr(1, bodytxt, "</value>") - 1) / 1000
Set oXH = Nothing
End Function
Ich habe einen Excel VBA Code auf einem Windows PC, der auf einem MAC mit Excel 2011 einfach nicht läuft, wer kann mir da weiterhelfen, brauche dies unbedingt, vielen herzlichen Dank für Eure Hilfe! Die Excel-Funktion Entfernung() gibt die Kilometer-Distanz zwischen zwei Orten zurück. Dazu wird im Hintergrund eine Abfrage über google-Maps gemacht.
Hier der Code:
Public Function Entfernung _
( _
Start_Strasse As String, Start_Stadt_PLZ As String, _
Start_Bundesland As String, Start_Staat As String, _
Ziel_Strasse As String, Ziel_Stadt_PLZ As String, _
Ziel_Bundesland As String, Ziel_Staat As String _
)
Dim surl As String
Dim oXH As Object
Dim bodytxt As String
surl = "http://maps.googleapis.com/maps/api/distancematrix/xml?origins=" & _
Replace(Start_Strasse, " ", "+") & "+" & Replace(Start_Stadt_PLZ, " ", "+") & "+" & _
Replace(Start_Bundesland, " ", "+") & "+" & Replace(Start_Staat, " ", "+") & _
"&destinations=" & _
Replace(Ziel_Strasse, " ", "+") & "+" & Replace(Ziel_Stadt_PLZ, " ", "+") & "+" & _
Replace(Ziel_Bundesland, " ", "+") & "+" & Replace(Ziel_Staat, " ", "+") & _
"&mode=driving&sensor=false&units=metric"
Set oXH = CreateObject("WinHttp.WinHttpRequest.5.1")
With oXH
.Open "get", surl, False
.send
bodytxt = .responseText
End With
bodytxt = Right(bodytxt, Len(bodytxt) - InStr(1, bodytxt, "<value>") - 5)
bodytxt = Right(bodytxt, Len(bodytxt) - InStr(1, bodytxt, "<value>") - 6)
Entfernung = Left(bodytxt, InStr(1, bodytxt, "</value>") - 1) / 1000
Set oXH = Nothing
End Function