EncodeURL Function

purceld2

Well-known Member
Joined
Aug 18, 2005
Messages
551
I am trying to use the above EncodeURL function in the code below and get

Compile error:

Sub or Function not defined.

Highlighting the Encodeurl function

Code:
Sub GetLatLong(strPostcode, strLatitude, strLongitude, strCountry)
Dim strGoogleApiKey
Dim strGooglePostcodeUrl
Dim objHTTP
Dim strHttpResponse
Dim objXML
 
                strGoogleApiKey = "AIzaSyAC9AXAQkOAljbc0jPs8AqyM8uiNqHzASk" 'get your own key from Google and put it in here
                
                strGooglePostcodeUrl = "http://maps.google.co.uk/maps/geo?output=csv&key=" & strGoogleApiKey & "&q=" & Encodeurl(strPostcode)
 
                Set objHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
                objHTTP.Open "GET", strGooglePostcodeUrl, False
                objHTTP.send
                strHttpResponse = objHTTP.responseText
                arrHttpResponse = Split(strHttpResponse, ",")
 
                'make sure the lookup hasn't returned an error 200 means success
                '200        G_GEO_SUCCESS            No errors occurred; the address was successfully parsed and its geocode was returned.
                '500        G_GEO_SERVER_ERROR               A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is unknown.
                '601        G_GEO_MISSING_QUERY           An empty address was specified in the HTTP q parameter.
                '602        G_GEO_UNKNOWN_ADDRESS                 No corresponding geographic location could be found for the specified address, possibly because the address is relatively new, or because it may be incorrect.
                '603        G_GEO_UNAVAILABLE_ADDRESS            The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.
                '610        G_GEO_BAD_KEY            The given key is either invalid or does not match the domain for which it was given.
                '620        G_GEO_TOO_MANY_QUERIES                 The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time. If you're sending multiple requests in parallel or in a tight loop, use a timer or pause in your code to make sure you don't send the requests too quickly.
 
                If arrHttpResponse(0) = 200 Then
                                strLatitude = arrHttpResponse(2)
                                strLongitude = arrHttpResponse(3)
                                strCountry = "GB"
                Else
                                strLatitude = vbNullString
                                strLongitude = vbNullString
                                strCountry = vbNullString
                End If
End Sub


Can somebody advise what i am doing wrong please
 

Some videos you may like

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

nuked

Well-known Member
Joined
Mar 20, 2013
Messages
883
Assuming 2013, try:

Application.WorksheetFunction.EncodeURL("xxx")
 

Watch MrExcel Video

Forum statistics

Threads
1,122,567
Messages
5,596,908
Members
414,110
Latest member
docops

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top