I'm trying to insert an image into a sheet with VBA using Base64 but I can't find any examples of how to do it correctly anywhere.
I have a string setup for the image, something like:
vLogo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZoAAABfCAY"
I just want to do the following, but instead of looking for an image file store the image in the VBA.
Sheets("Sheet1").Pictures.Insert (Application.ActiveWorkbook.Path & "vLogo.png")
I've even looked at doing something like:
' Write the image to file
Dim myFile As String
myFile = Application.ActiveWorkbook.Path & "emp.png"
Open myFile For Output As #1
Write #1, vLogo
Close #1
' Insert the image
Sheets("Sheet1").Pictures.Insert (Application.ActiveWorkbook.Path & "emp.png")
' Delete the temp file
Kill Application.ActiveWorkbook.Path & "emp.png"
But I can't figure out how to write the base64 encoded image to file.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…