kperelman
asked on
how to convert xml base64 string gif/jpg/png image file using vba
I am not sure why this is not working?
I am using vba:
If have a base64 gif string (here's the excerpt):
R0lGODlhsAQIB/cAAAAAAI ... <more here> ... u+I1r3rdK1/76te/Ajawgh1jQA AAOw==
I attempted to create a binary file by loading the xml above into a string: base64_string
dim btArr() As Byte
dim base64_string as string
base64_string=<xml from above>
btArr = base64_string
Open 'image.gif" For Binary As #1
Put #1, 1, Base64decode(btArr)
Close #1
But when I try to see the image by opening the file, it says the image format is invalid.
What else do I need to do to make the file a gif file?
I am using vba:
If have a base64 gif string (here's the excerpt):
R0lGODlhsAQIB/cAAAAAAI ... <more here> ... u+I1r3rdK1/76te/Ajawgh1jQA
I attempted to create a binary file by loading the xml above into a string: base64_string
dim btArr() As Byte
dim base64_string as string
base64_string=<xml from above>
btArr = base64_string
Open 'image.gif" For Binary As #1
Put #1, 1, Base64decode(btArr)
Close #1
But when I try to see the image by opening the file, it says the image format is invalid.
What else do I need to do to make the file a gif file?
ASKER
Thanks.
The function works fine.
Is there an algorythm written in a vba function that does the same thing?
The function works fine.
Is there an algorythm written in a vba function that does the same thing?
You like to have structures from XML library in vba?
ASKER
For the project the algorythm is what I was looking for to endcode and decode.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.nonhostile.com/howto-encode-decode-base64-vb6.asp
works for me.
Open in new window
You need reference to Microsoft XML library (I've used 6.0)