I am trying to insert an image into a sheet with VBA using Base64, but I cannot find examples of how to do this anywhere.
I have a string setting for the image, for example:
vLogo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZoAAABfCAY"
I just want to do the following, but instead of looking for the image file, save the image in VBA.
Sheets("Sheet1").Pictures.Insert (Application.ActiveWorkbook.Path & "\vLogo.png")
I even looked at something like:
' Write the image to file
Dim myFile As String
myFile = Application.ActiveWorkbook.Path & "\temp.png"
Open myFile For Output As
Write
Close
' Insert the image
Sheets("Sheet1").Pictures.Insert (Application.ActiveWorkbook.Path & "\temp.png")
' Delete the temp file
Kill Application.ActiveWorkbook.Path & "\temp.png"
But I can't figure out how to write a base64 encoded image to a file.
source
share