我正在尝试使用某人的反向地理编码宏来帮助其他宏本的功能。这是代码:
Public Function ReverseGeoCode(myInput1 As String, myInput2 As String) As String
'You will need to reference Microsoft XML, v6.0 object library
Dim XMLDoc As New DOMDocument
Dim XMLNODE As IXMLDOMNode
Dim I As Long
Dim lat, lng, myAddress As String
lat = myInput1
lng = myInput2
XMLDoc.Load "http://maps.googleapis.com/maps/api/geocode/xml?latlng=" & lat & "," & lng & " &sensor=false"
Do Until XMLDoc.readyState = 4
DoEvents
Loop
If Len(XMLDoc.Text) = 0 Then
Call MsgBox("No Data!")
Exit Function
End If
Set XMLNode = XMLDoc.SelectSingleNode("/GeocodeResponse/result/formatted_address")
For i= 0 To XMLNode.ChildNotes.Length - 1
myAddress = XMLNode.ChildNotes(i).Text
Next i
ReverseGeoCode = myAddress
End Function
我对这段代码所做的任何事情都不是很熟悉。我按照说明引用了Microsoft XML v6.0对象库,但是当我尝试调用该函数时,单元格将显示“ #VALUE!”。在代码中,我在第一个DOMDocument
语句中突出显示了Dim
,并显示错误消息“未定义用户定义的类型”
有人知道这里发生了什么吗?