4

QUESTION

How to read or convert a base64 image string with Microsoft Access vba?

REQUIREMENTS

A base64 image string is stored in a ms sqlserver database as below:

BASE64

data:image/png;base64,iVBORw0KGgoAAAA...

Using vba I am attempting to read the string from the database using microsoft vba.


I know vba is capable of reading a string from the database to output the image on screen as I currently achieve this result by reading the image as a hex sting as below:

HEX

89504E470D0A1A0A0000000D49484...

So how can vba read a base64 image string to display the image on screen within Microsoft Access?

DreamTeK
  • 32,537
  • 27
  • 112
  • 171
  • 1
    Why do people down vote without cause or explanation? Offer suggestion how to improve the question and consequently the website. – DreamTeK Jun 19 '14 at 11:13
  • what is the database, really SQL Server or Access? and what are you really using to connect to it, vba or VB6 (which is not a new or efficient web technology). – Ňɏssa Pøngjǣrdenlarp Jun 19 '14 at 11:31
  • Data base is sqlserver. Reading the database is vba. – DreamTeK Jun 19 '14 at 11:47
  • One possible reason for the downvote is that your question is vague. Q: "Is it possible...?" A: Yes, it is. Anything more specific will depend on what you want to do with the image after it has been decoded. "Change is now required to accomodate new and more efficient web technologies" is not an adequate description. As for the decoding method itself did you by chance do a web search for 'access base64 decode' ...? – Gord Thompson Jun 19 '14 at 12:04
  • @GordThompson Thank you this is helpful I will revise my question to compensate. – DreamTeK Jun 19 '14 at 12:11
  • Old Q, but it'd be nice if you could link to whatever method you found for converting Hex->image – Greedo Jun 22 '17 at 08:18
  • 1
    @Greedo I'm afraid this question is past it's cell by date. I don't recall but I don't think I converted at all, I ended up saving both formats in the database. – DreamTeK Jun 22 '17 at 09:35

1 Answers1

3

I know vba is capable of reading a string from the database to output the image on screen as I currently achieve this result by reading the image as a hex sting as below:

HEX

89504E470D0A1A0A0000000D49484...

So really what you are asking is how to decode the Base64 string to a hex string. In that case you just want strip off the data:image/png;base64, prefix and pass the rest to a function like Decode64() as described in this answer.

Community
  • 1
  • 1
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418