Skip to content

Instantly share code, notes, and snippets.

@theredstapler
Created January 24, 2016 13:36
Show Gist options
  • Save theredstapler/88a612fd1d7510e2dc51 to your computer and use it in GitHub Desktop.
Save theredstapler/88a612fd1d7510e2dc51 to your computer and use it in GitHub Desktop.
Base64 encoding with VBA
Sub Button1_Click()
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Dim arrData() As Byte
arrData = StrConv(Cells(1, 1), vbFromUnicode)
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
MsgBox objNode.Text
End Sub
@Juan3103
Copy link

Juan3103 commented Nov 5, 2017

Hi, how do i tweak the same code to convert a file to base64. Say i have a file and file path in cell A1. Cell A1 contains the text ("C:\testing\test1.xls"). I want to base64 test1.xls to string. I want to loop through all the files in column A. Any help is appreciated.

Thanks!
Juan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment