Excel VBA不编译 – MD5哈希函数

现在试图在Excel 2011 for Mac中实现一个VBA模块,我通过interwebsfind了。 以下模块在您看到As String的第三行失败:

 Option Explicit Public Function MD5Hash( _ ByVal strText As String) _ As String ' Create and return MD5 signature from strText. ' Signature has a length of 32 characters. ' ' 2005-11-21. Cactus Data ApS, CPH. Dim cMD5 As New clsMD5 Dim strSignature As String ' Calculate MD5 hash. strSignature = cMD5.MD5(strText) ' Return MD5 signature. MD5Hash = strSignature Set cMD5 = Nothing End Function Public Function IsMD5( _ ByVal strText As String, _ ByVal strMD5 As String) _ As Boolean ' Checks if strMD5 is the MD5 signature of strText. ' Returns True if they match. ' Note: strText is case sensitive while strMD5 is not. ' ' 2005-11-21. Cactus Data ApS, CPH. Dim booMatch As Boolean booMatch = (StrComp(strMD5, MD5Hash(strText), vbTextCompare) = 0) IsMD5 = booMatch End Function 

VBA编译器错误

希望有人能帮助我,因为这是我第一次玩VBA。 感谢帮助!

更新

错误消息文本:

用户定义types未定义

我想出了这个问题,看起来像我对VBA界面的知识缺乏。 原来我的Class Module没有正确命名。 我从头开始重build模块,VBA能够在另一行上给我一个不同的错误,指向clsMD5的引用。 这是我如何解决它:

1)按alt+F11打开VBA“窗口”

2)使用“属性”窗口编辑类模块的名称,在上面的问题我需要更改名称clsMD5

属性窗口VBA