Skip to content

Instantly share code, notes, and snippets.

@cwg999
Created September 8, 2017 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwg999/51bafc6cc5f28308ca219e0b43b1aff2 to your computer and use it in GitHub Desktop.
Save cwg999/51bafc6cc5f28308ca219e0b43b1aff2 to your computer and use it in GitHub Desktop.
encodeURIComponent in VBA for Excel
Function encodeURIComponent(strText As String) As String
Static objHtmlfile As Object
If objHtmlfile Is Nothing Then
Set objHtmlfile = CreateObject("htmlfile")
' objHtmlfile.parentWindow.execScript "function encode(s) {return encodeURIComponent(s)}", "jscript"
End If
encodeURIComponent = objHtmlfile.parentWindow.encodeURIComponent(strText)
End Function
Function decodeURIComponent(strText As String) As String
Static objHtmlfile As Object
If objHtmlfile Is Nothing Then
Set objHtmlfile = CreateObject("htmlfile")
' objHtmlfile.parentWindow.execScript "function encode(s) {return encodeURIComponent(s)}", "jscript" ' if you wanted to add a custom function
End If
decodeURIComponent = objHtmlfile.parentWindow.decodeURIComponent(strText)
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment