Hello everyone,
There is a function called url encode in MS excel 2003. Is it also there in MS excel 2007? Can anyone tell me how can i use it?
All suggestions are welcome.
Printable View
Hello everyone,
There is a function called url encode in MS excel 2003. Is it also there in MS excel 2007? Can anyone tell me how can i use it?
All suggestions are welcome.
Try the Excel VBA and Excel UserForms Training 1 tool for guideline to use url encode in excel. You can access it from directly from excel tools menu by clicking on the new menu item. It is visual basic editor tool features Objects and Properties, Excel Objects , Object Hierarchy, Application, Workbook, Worksheet, Range, CommandBars, Variables and Constants, Data types, Variable Levels, Declaring Variables, Constants, Loops, Types of Loops, Loop Pitfalls, Effective Decision Making, If/And/Or, Select Case, Dates and Times, Workbook and Worksheet Events, Debugging and Error Handling, Prevention.
Try the following URL Encoder and Decoder for VB:
Source: freevbcode.comQuote:
Public Function URLEncode(StringToEncode As String, Optional _
UsePlusRatherThanHexForSpace As Boolean = False) As String
Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToEncode)
Select Case Asc(Mid(StringToEncode, CurChr, 1))
Case 48 To 57, 65 To 90, 97 To 122
TempAns = TempAns & Mid(StringToEncode, CurChr, 1)
Case 32
If UsePlusRatherThanHexForSpace = True Then
TempAns = TempAns & "+"
Else
TempAns = TempAns & "%" & Hex(32)
End If
Case Else
TempAns = TempAns & "%" & _
Format(Hex(Asc(Mid(StringToEncode, _
CurChr, 1))), "00")
End Select
CurChr = CurChr + 1
Loop
URLEncode = TempAns
End Function
Public Function URLDecode(StringToDecode As String) As String
Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToDecode)
Select Case Mid(StringToDecode, CurChr, 1)
Case "+"
TempAns = TempAns & " "
Case "%"
TempAns = TempAns & Chr(Val("&h" & _
Mid(StringToDecode, CurChr + 1, 2)))
CurChr = CurChr + 2
Case Else
TempAns = TempAns & Mid(StringToDecode, CurChr, 1)
End Select
CurChr = CurChr + 1
Loop
URLDecode = TempAns
End Function
' URLDecode function in Perl for reference
' both VB and Perl versions must return same
'
' sub urldecode{
' local($val)=@_;
' $val=~s/\+/ /g;
' $val=~s/%([0-9A-H]{2})/pack('C',hex($1))/ge;
' return $val;
' }
You can get help with the online module on Microsoft office 2007. There are pretty good explanations on how to use tools and features of MS Excel 2007. Check the following link for getting started: http://office.microsoft.com/en-us/ge...938921033.aspx