Search code examples
urlvbaurldecode

Does VBA have any built in URL decoding?


I just need to decode a URL, for example, replace %2E with . I can hack out a method if one isn't build in, but my assumption is that there must be a URL decoding tool already existing.


Solution

  • No.

    But here's one: URL Encoder and Decoder for VB

    Or something along the lines of (possibly not complete):

    Public Function URLDecode(ByVal strEncodedURL As String) As String
       Dim str As String
       str = strEncodedURL 
       If Len(str) > 0 Then
          str = Replace(str, "&amp", " & ")
          str = Replace(str, "&#03", Chr(39))
          str = Replace(str, "&quo", Chr(34))
          str = Replace(str, "+", " ")
          str = Replace(str, "%2A", "*")
          str = Replace(str, "%40", "@")
          str = Replace(str, "%2D", "-")
          str = Replace(str, "%5F", "_")
          str = Replace(str, "%2B", "+")
          str = Replace(str, "%2E", ".")
          str = Replace(str, "%2F", "/")
    
          URLDecode = str
      End If
    
    End Function
    

    Also, take a look at How can I URL encode a string in Excel VBA?