There is a UserForm with several instances of a 3rd-party ActiveX grid control (iGrid by 10Tec). We have a sub that inits every grid using the same statements:
Sub SetupIgrid(ig as iGrid)
ig.RowMode = True
ig.MultiSelect = True
ig.Appearance = igAppearanceFlat
ig.Editable = False
End Sub
We cannot pass an iGrid instance to this sub – Excel VBA always displays the ‘type mismatch’ error in calls like this:
SetupIgrid igAuds
Nothing other helped. For instance, we can pass an iGrid like a Variant or Object parameter, but when we try to extract the real iGrid type from it, we get the same type mismatch:
Sub SetupIgrid(igObj as Object)
Dim ig as iGrid
Set ig = igObj
Even if we use a hack to pass a Long pointer to iGrid we get with ObjPtr and then convert it back to the iGrid type with the API CopyMemory, MS Excel VBA cannot access the iGrid members.
The key point of this task is to have the real iGrid object in the SetupIgrid sub to use the IntelliSense feature. Now we can have it obly as Object (Variant) or something else, but sure this does not give us the IntelliSense list when we press dot.
This is because controls were not intended to be passed outside of their host in this manner. What is being passed “behind the scenes” is the wrapper’s early-bound “Extender” control which, in turn, causes the Type Mismatch you’re seeing.
There is a more full treatment of this issue here from Microsoft.