I was sick of the old code I used to use to do this - when using large dimensions it could get quite slow so, I decided to investigate if it was possible using API and as it turns out it is, here is what I came up with:

VB Code:
  1. Private Declare Sub RtlMoveMemory Lib "kernel32.dll" ( _
  2.     ByRef Destination As Any, _
  3.     ByRef Source As Any, _
  4.     ByVal Length As Long)
  5.  
  6. Private Const VT_BYREF = &H4000&
  7.  
  8. Private Function ArrayDims(varArray As Variant) As Integer
  9.     Dim lngPointer As Long
  10.     Dim intType As Integer
  11.    
  12.     RtlMoveMemory intType, varArray, 2
  13.     If (intType And vbArray) = 0 Then
  14.         Exit Function
  15.     End If
  16.     RtlMoveMemory lngPointer, ByVal VarPtr(varArray) + 8, 4
  17.     If (intType And VT_BYREF) Then
  18.         RtlMoveMemory lngPointer, ByVal lngPointer, 4
  19.     End If
  20.     If lngPointer Then
  21.         RtlMoveMemory ArrayDims, ByVal lngPointer, 2
  22.     End If
  23. End Function

Hope that helps someone,

Cheers,

RyanJ