We are using a 3rd-party ActiveX grid control 10Tec iGrid in an Excel 2016 VBA application on a UserForm. We need to retrieve this control by the string name generated dynamically and cast it to its native type for further operations.
This is very easy to do for intrinsic MSForms types like CommandButton, for example:
Dim cmdbtn As iGrid
Set cmdbtn = Me.Controls("cmdOk")
However, this approach does not work for iGrid:
Dim grid As iGrid
Set grid = Me.Controls("iGrid1")
We always get the
Type mismatch
error.
This also does not help (the same problem):
Dim grid As iGrid
Set grid = Me.Controls("iGrid1").Object
Is there a way to get an ActiveX control in its native type dynamically by its string name in VBA UserForms?