How to convert an attached image to Base64 format.
Solved/Closed
Raj_1562
Posts
29
Registration date
Wednesday 26 August 2020
Status
Member
Last seen
29 August 2022
-
18 Jan 2021 à 09:34
Raj - 28 Jan 2021 à 22:46
Raj - 28 Jan 2021 à 22:46
Related:
- Excel to base64
- Excel mod apk for pc - Download - Spreadsheets
- Vat calculation excel - Guide
- Kernel for excel repair - Download - Backup and recovery
- Number to words in excel - Guide
- How to copy data from one excel sheet to another - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday 12 September 2010
Status
Contributor
Last seen
27 December 2022
555
28 Jan 2021 à 12:18
28 Jan 2021 à 12:18
Hi Raj,
I'm not familiar with Base64. I did find this code on the world wide web:
Place the code in a standard module. In excel use it as any other function: =EncodeFile(cell reference with the entire path of the picture)
Best regards,
Trowa
I'm not familiar with Base64. I did find this code on the world wide web:
Public Function EncodeFile(strPicPath As String) As String
Const adTypeBinary = 1 ' Binary file is encoded
' Variables for encoding
Dim objXML
Dim objDocElem
' Variable for reading binary picture
Dim objStream
' Open data stream from picture
Set objStream = CreateObject("ADODB.Stream")
objStream.Type = adTypeBinary
objStream.Open
objStream.LoadFromFile (strPicPath)
' Create XML Document object and root node
' that will contain the data
Set objXML = CreateObject("MSXml2.DOMDocument")
Set objDocElem = objXML.createElement("Base64Data")
objDocElem.dataType = "bin.base64"
' Set binary value
objDocElem.nodeTypedValue = objStream.Read()
' Get base64 value
EncodeFile = objDocElem.Text
' Clean all
Set objXML = Nothing
Set objDocElem = Nothing
Set objStream = Nothing
End Function
Place the code in a standard module. In excel use it as any other function: =EncodeFile(cell reference with the entire path of the picture)
Best regards,
Trowa

28 Jan 2021 à 22:46
Appreciated.
Regards,
Raj