VBA equivalent of encodeURI

R

robot

I am try to find a VBA command that does the same thing as the JavaScript
function encodeURI(). Naturally I searched the internet, but without
success. Any help would be appreciated.

I am using Word XP and Windows XP.
 
K

Karl E. Peterson

robot said:
I am try to find a VBA command that does the same thing as the JavaScript
function encodeURI(). Naturally I searched the internet, but without
success. Any help would be appreciated.

I'm not familiar with encodeURI(), but I'd have to guess it does something similar
to this:

Private Declare Function UrlEscape Lib "Shlwapi.dll" Alias "UrlEscapeA" (ByVal
pszURL As String, ByVal pszEscaped As String, ByRef pcchEscaped As Long, ByVal
dwFlags As Long) As Long

Private Const URL_DONT_ESCAPE_EXTRA_INFO As Long = &H2000000

Private Function EscapeURL(ByVal URL As String) As String
' Purpose: A thin wrapper for the URLEscape API function.
Dim EscTxt As String
Dim nLen As Long

' Create a maximum sized buffer.
nLen = Len(URL) * 3
EscTxt = Space$(nLen)

If UrlEscape(URL, EscTxt, nLen, URL_DONT_ESCAPE_EXTRA_INFO) = 0 Then
EscapeURL = Left$(EscTxt, nLen)
End If
End Function

(The above was indented to highlight wordwrap.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top