Is there a built-in way to URL encode a string in Excel VBA or do I need to hand roll this functionality?
Since office 2013 use this inbuilt function here.
If before office 2013
Function encodeURL(str As String)
Dim ScriptEngine As ScriptControl
Set ScriptEngine = New ScriptControl
ScriptEngine.Language = "JScript"
ScriptEngine.AddCode "function encode(str) {return encodeURIComponent(str);}"
Dim encoded As String
encoded = ScriptEngine.Run("encode", str)
encodeURL = encoded
End Function
Add Microsoft Script Control as reference and you are done.
Same as last post just complete function ..works!