-Code funktioniert gut, wenn ich Funktion von VBA zugreifen jedoch, wenn ich die gleiche Funktion in Excel-Zelle nennen (postalcode("23.0776120,72.6538530")
, ich #value Fehler bekommen Mein Code ist.#value Fehler während benutzerdefinierte Funktion in VBA Zugriff auf
Function PostalCode(latlng As String) As String
Dim xmlDoc As MSXML2.DOMDocument60
Dim xEmpDetails As MSXML2.IXMLDOMNode
Dim xParent As MSXML2.IXMLDOMNode
Dim xChild As MSXML2.IXMLDOMNode
Dim Col, Row As Integer
Set xmlDoc = New MSXML2.DOMDocument60
xmlDoc.async = False
xmlDoc.validateOnParse = False
' use XML string to create a DOM, on error show error message
If Not xmlDoc.Load("https://maps.googleapis.com/maps/api/geocode/xml?latlng=" & latlng) Then
Err.Raise xmlDoc.parseError.ErrorCode, , xmlDoc.parseError.reason
End If
Set xEmpDetails = xmlDoc.DocumentElement
Set xParent = xEmpDetails.FirstChild
Row = 1
Col = 1
Dim xmlNodeList As IXMLDOMNodeList
Set xmlNodeList = xmlDoc.SelectNodes("//formatted_address")
Worksheets("Sheet1").Cells(1, 6).Value = xmlNodeList.Item(0).Text
Dim xyz As String
PostalCode = xmlNodeList.Item(0).Text
' PostalCode = "Not Found (try again, you may have done too many too fast)"
MsgBox PostalCode
End Function
Vielen Dank !! Nach dem Kommentieren von "Arbeitsblättern (" Sheet1 "). Zellen (1,6) .Wert" .. Ich habe das Ergebnis .. – Max