Good day,
I managed to get the following VBA below a while back from somewhere and it was working and now all of sudden I am getting an error and can't seem to find a solution. Hope fully someone can assist.
The error I am getting is
Compile error:
User-define type not defined
The part highlighted in red seems to be the problem
I managed to get the following VBA below a while back from somewhere and it was working and now all of sudden I am getting an error and can't seem to find a solution. Hope fully someone can assist.
The error I am getting is
Compile error:
User-define type not defined
The part highlighted in red seems to be the problem
Code:
Function MyGeocode(address As String) As String Dim strAddress As String
Dim strQuery As String
Dim strLatitude As String
Dim strLongitude As String
strAddress = URLEncode(address)
'Assemble the query string
strQuery = "http://maps.googleapis.com/maps/api/geocode/xml?"
strQuery = strQuery & "address=" & strAddress
strQuery = strQuery & "&sensor=false"
'define XML and HTTP components
[COLOR=#ff0000] Dim googleResult As New MSXML2.DOMDocument[/COLOR]
[COLOR=#ff0000] Dim googleService As New MSXML2.XMLHTTP[/COLOR]
Dim oNodes As MSXML2.IXMLDOMNodeList
Dim oNode As MSXML2.IXMLDOMNode
'create HTTP request to query URL - make sure to have
'that last "False" there for synchronous operation
googleService.Open "GET", strQuery, False
googleService.send
googleResult.LoadXML (googleService.responseText)
Set oNodes = googleResult.getElementsByTagName("geometry")
If oNodes.Length = 1 Then
For Each oNode In oNodes
strLatitude = oNode.ChildNodes(0).ChildNodes(0).Text
strLongitude = oNode.ChildNodes(0).ChildNodes(1).Text
MyGeocode = strLatitude & "," & strLongitude
Next oNode
Else
MyGeocode = "Not Found (try again, you may have done too many too fast)"
End If