VBA中哈希实现中的错误-运行时错误-2146232576(80131700) [英] Error in Hash Implementation in VBA - Runtime Error -2146232576 (80131700)
问题描述
我已经实现了帖子中建议的哈希方法:
I have implemented the hash method as suggested on the post:
这是我的实现方式
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下运行.
Everything was working great, running under excel 2013
(Portuguese), windows 8.1 (Portuguese) and windows 7.
虽然,当我开始使用另一台使用相同Excel 2013(葡萄牙语)但Windows 8.1(英文版)的计算机时,不确定为什么以及如果这是原因,但是出现了错误,并且调试器突出显示了在变量声明之后,在BASE64SHA1函数的第一行:
Although, when I start using other computer which uses the same Excel 2013 (Portuguese) but the windows 8.1 (English Version), not sure why and if this is the reason, but it came up with the error and the debugger highlight at the first line in BASE64SHA1 function, after variables declaration:
设置asc = CreateObject("System.Text.UTF8Encoding")
错误:
运行时错误-2146232576(80131700)
Runtime Error -2146232576 (80131700)
我检查了错误消息,并附带以下详细信息:
I checked the error messages and came with the details below:
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
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
有人遇到同样的问题吗?或对此有帮助吗?看起来我缺少参考或其他什么东西...但是我声明为Object,并且在其他PC上也能正常工作...帮助!=(
Did anyone get the same issue? or could help on that? Looks like I am missing a Reference or something... but I declared as Object and it worked fine in other PC´s... help! =(
非常感谢!
推荐答案
在MSDN().
那里的问题通过安装Microsoft .NET Framework 2.0 SP2(也自动安装了3.5)解决了.
The problem there was solved by installing Microsoft .NET Framework 2.0 SP2 (which automatically also installed 3.5).
这篇关于VBA中哈希实现中的错误-运行时错误-2146232576(80131700)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!