VBA中哈希实现中的错误 – 运行时错误-2146232576(80131700)

我已经实现了这个post中build议的哈希方法:

VBA是否有Hash_HMAC

这是我的实现:

Public Function BASE64SHA1(ByVal sTextToHash As String) Dim asc As Object Dim enc As Object Dim TextToHash() As Byte Dim SharedSecretKey() As Byte Dim bytes() As Byte Set asc = CreateObject("System.Text.UTF8Encoding") Set enc = CreateObject("System.Security.Cryptography.HMACSHA1") TextToHash = asc.GetBytes_4(sTextToHash) SharedSecretKey = asc.GetBytes_4(sTextToHash) enc.Key = SharedSecretKey bytes = enc.ComputeHash_2((TextToHash)) BASE64SHA1 = EncodeBase64(bytes) Set asc = Nothing Set enc = Nothing End Function Private Function EncodeBase64(ByRef arrData() As Byte) As String Dim objXML As Object Dim objNode As Object Set objXML = CreateObject("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 

一切都很好,运行在excel 2013 (葡萄牙语),Windows 8.1(葡萄牙语)和Windows 7下。

虽然,当我开始使用其他计算机使用相同的Excel 2013(葡萄牙语),但Windows 8.1(英文版),不知道为什么,如果这是原因,但它提出了错误和debugging器在第一在BASE64SHA1函数中,variables声明后:

Set asc = CreateObject("System.Text.UTF8Encoding")

错误:

运行时错误-2146232576(80131700)

我检查了错误消息,并附带了下面的细节:

err.Source – VBAProject
err.HelpContext – 1000440
err.HelpFile – C:\ Program Files(x86)\ Common Files \ Microsoft Shared \ VBA \ VBA7.1 \ 1046 \ VbLR6.chm
err.LastDllError – 0

有没有人得到同样的问题? 或者可以帮助呢? 看起来像我缺less一个引用或东西…但我声明为对象,并在其他PC的工作正常…帮助! =(

非常感谢!