Posts

Showing posts with the label urlencode

How can I URL encode a string in Excel VBA?

Image
Clash Royale CLAN TAG #URR8PPP How can I URL encode a string in Excel VBA? Is there a built-in way to URL encode a string in Excel VBA or do I need to hand roll this functionality? 14 Answers 14 No, nothing built-in ( until Excel 2013 - see this answer ). There are three versions of URLEncode() in this answer. URLEncode() A variant that supports UTF-8 encoding and is based on ADODB.Stream (include a reference to a recent version of the "Microsoft ActiveX Data Objects" library in your project): ADODB.Stream Public Function URLEncode( _ StringVal As String, _ Optional SpaceAsPlus As Boolean = False _ ) As String Dim bytes() As Byte, b As Byte, i As Integer, space As String If SpaceAsPlus Then space = "+" Else space = "%20" If Len(StringVal) > 0 Then With New ADODB.Stream .Mode = adModeReadWrite .Type = adTypeText .Charset = "UTF...