¿Cómo generar md5-hashes para archivos grandes con VBA?

Tengo las siguientes funciones para generar md5-hashes para archivos. Las funciones funcionan muy bien para archivos pequeños, pero se bloquean y generanError de tiempo de ejecución 7: memoria insuficiente cuando trato de hacer un hash de archivos de más de ~ 250 MB (en realidad no sé en qué tamaño exacto se rompe, pero los archivos de menos de 200 MB funcionan bien).

No entiendo por qué se rompe en un cierto tamaño, por lo que si alguien pudiera arrojar algo de luz sobre eso, lo agradecería mucho.

Además, ¿hay algo que pueda hacer para que las funciones manejen archivos más grandes? Tengo la intención de utilizar las funciones en una herramienta más grande donde tendré que generar hashes para archivos de tamaños desconocidos. La mayoría será lo suficientemente pequeña como para que funcionen las funciones actuales, pero también tendré que manejar archivos grandes.

Obtuve mis funciones actuales de la respuesta más votada en esta publicación¿Cómo obtener el hash hexadecimal MD5 para un archivo usando VBA?

Public Function FileToMD5Hex(ByVal strFileName As String) As String
Dim varEnc           As Variant
Dim varBytes         As Variant
Dim strOut           As String
Dim intPos           As Integer

Set varEnc = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")

'Convert the string to a byte array and hash it
varBytes = GetFileBytes(strFileName)
varBytes = varEnc.ComputeHash_2((varBytes))

'Convert the byte array to a hex string
For intPos = 1 To LenB(varBytes)
   strOut = strOut & LCase(Right("0" & Hex(AscB(MidB(varBytes, intPos, 1))), 2))
Next

FileToMD5Hex = strOut

Set varEnc = Nothing

End Function

Private Function GetFileBytes(ByVal strPath As String) As Byte()
Dim lngFileNum          As Long
Dim bytRtnVal()         As Byte

lngFileNum = FreeFile

'If file exists, get number of bytes
If LenB(Dir(strPath)) Then
   Open strPath For Binary Access Read As lngFileNum
   ReDim bytRtnVal(LOF(lngFileNum)) As Byte
   Get lngFileNum, , bytRtnVal
   Close lngFileNum
Else
   MsgBox "Filen finns inte" & vbCrLf & "Avbryter", vbCritical, "Filen hittades inte"
   Exit Function
End If

GetFileBytes = bytRtnVal
Erase bytRtnVal

End Function

Gracias

Respuestas a la pregunta(2)

Su respuesta a la pregunta