我如何采用base64 EN code字符串有效地使用Excel VBA?
问题描述:
我要带code一个100KB +字符串作为VBA BASE64。是否有任何内置函数或COM对象的使用,这将做到这一点作为一个纯粹的VBA的做法要么是复杂的,或在这些卷不能很好地扩展(看到的dbb 和 marxidad )?
I need to encode a 100KB+ string as base64 in VBA. Are there any built-in functions or COM objects available which will do this as a pure VBA approach is either complex or doesn't scale well at these volumes (see links from dbb and marxidad)?
答
作为www.nonhostile.com/howto-en$c$c-de$c$c-base64-vb6.asp:
Function EncodeBase64(text As String) As String
Dim arrData() As Byte
arrData = StrConv(text, vbFromUnicode)
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.dataType = "bin.base64"
objNode.nodeTypedValue = arrData
EncodeBase64 = objNode.Text
Set objNode = Nothing
Set objXML = Nothing
End Function