0

Right now trying to implement a VBA module in Excel 2011 for Mac I found through the interwebs. The following module fails on the third line where you see 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 compiler error

Hopefully someone can help chime in, since this is my first time playing with VBA. Appreciate the help!

Update

The error message text:

User-defined type not defined

3
  • Have you tried removing the line continuations? Also what is the error? Commented Sep 4, 2014 at 22:14
  • 1
    What's the error message ? Commented Sep 4, 2014 at 22:14
  • Whoops sorry @cronos2546 @Alexandre the error message is User-defined type not defined and I've actually fixed this problem, adding the solution below Commented Sep 4, 2014 at 22:17

1 Answer 1

1

I figured out the problem, looks like my lack of knowledge of the interface with VBA. Turns out my Class Module was not named properly. I ended up rebuilding the module from scratch and VBA was able to give me a different error on a different line, pointing to a reference to clsMD5. Here's how I fixed it:

1) Open the VBA "window" by pressing alt+F11

2) Use the "Properties" window to edit the name of the class module, in the problem above I needed to change the name to clsMD5

Properties window VBA

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.