Overview

When using an Excel Visual Basic for Applications (VBA) macro to access Velixo functionality, an Out of Memory error can be experienced:

Text of the error:

Compile Error: Out of Memory

Cause

Another error is occurring, but Excel's VBA interface is unable to adequately display it but keeps trying until it eventually runs out of memory.

Resolution

We need to provide a method for displaying the actual error that occurs.

Assuming that we originally were using the code shown above...

Public Sub Generate()
Dim Velixo As Velixo_Reports.VBA
Set Velixo = CreateObject("Velixo.Reports.Vba")
Velixo.ProcessAllAutoHideRanges
End Sub

... here is the corrected VBA code which uses On Error to capture the actual error and redirect to an area of the code for displaying that error:

Public Sub Generate() 
On Error GoTo EH

Dim Velixo As Velixo_Reports.VBA
Set Velixo = CreateObject("Velixo.Reports.Vba")
Velixo.ProcessAllAutoHideRanges

Done:
Exit Sub

EH:
MsgBox Err.Description, vbError

End Sub
Did this answer your question?