View Full Version : Decode Base64 to String in VBA to Excel cell
manurockz007
03-08-2017, 10:36 PM
Hi,
I am using following code to convert but i am unable to do it.
Sub DecodeBase64()
Dim cn As Integer
cn = 3
Dim base64Encoded As String
base64Encoded = ThisWorkbook.Sheets("Sheet1").Cells.Item(cn, "AE")
Dim base64Decoded As String
base64Decoded = Base64DecodeString(base64Encoded)
End Sub
Output:
"{"context":{"page":{"path":"/wordpress/index.php/2016/12/13/realhope-content-page/","refe"
How to get an exact string removing all the special characters means boxes in between.
Thanks.
mancubus
03-09-2017, 01:14 AM
wlecome to the forum.
take time read the forum rules pls.
post your code in between code tags.
that said, what is your input to produce the desired output.
don't use redundant variables.
Sub DecodeBase64()
Dim base64Decoded As String
base64Decoded = Base64DecodeString(ThisWorkbook.Sheets("Sheet1").Range("AE3").Value)
End Sub
post the UDF Base64DecodeString (or the link to the web site you have lifted it from) too.
manurockz007
03-09-2017, 01:29 AM
This is my input
"ewAiAGMAbwBuAHQAZQB4AHQAIgA6AHsAIgBwAGEAZwBlACIAOgB7ACIAcABhAHQAaAAiADoAIgA vAHcAbwByAGQAcAByAGUAcwBzAC8AaQBuAGQAZQB4AC4AcABoAHAALwAyADAAMQA2AC8AMQAyAC 8AMQAzAC8AcgBlAGEAbABoAG8AcABlAC0AYwBvAG4AdABlAG4AdAAtAHAAYQBnAGUALw"
which is Base64 need to convert to string while converting i am facing issues.
manurockz007
03-09-2017, 01:33 AM
Thanks for your reply but still i am getting same output
mancubus
03-09-2017, 01:49 AM
upload your workbook pls.
manurockz007
03-09-2017, 01:57 AM
Uploaded workbook
mancubus
03-09-2017, 04:09 AM
there is plenty of code which i am not familiar with.
currently i dont have the time to review them and offer a solution.
i hope one of our members can help you on this subject.
mancubus
03-09-2017, 04:20 AM
you may wish to see
http://web.archive.org/web/20060527094535/http://www.nonhostile.com/howto-encode-decode-base64-vb6.asp
http://www.vbforums.com/showthread.php?379072-VB-Fast-Base64-Encoding-and-Decoding
Paul_Hossler
03-09-2017, 07:08 AM
Not sure what problem you were having, but this seems to work
Option Explicit
Sub ColAE()
Dim r As Range, c As Range
Set r = ActiveSheet.Range("AE3")
Set r = Range(r, r.End(xlDown))
For Each c In r.Cells
c.Value = StrConv(Base64DecodeString(c.Value), vbFromUnicode)
Next
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.