I have a TreeView
in a form (specifically Microsoft TreeView Control, version 6.0
), and whilst it doesn't play so nicely with the VBE's Intellisense, I'm able to use all its properties, functions, etc.
Unfortunately, I seem unable to do this:
Dim tvw As TreeView
Set tvw = Me.MyTreeView 'The control on the form
I get a type mismatch error. So I fired up the Immediate window and had a look at the type of my form's TreeView:
? TypeName(Me.MyTreeView)
CustomControl
It seems that, for whatever reason, VBA is treating my TreeView
object as a CustomControl
object.
How can I convert CustomControl
back to TreeView
(or make VBA treat it as a 'TreeView' in the first place)? Type casting doesn't seem to exist in VBA (at least, VB's CType
function does not work). I'm writing a wrapper class for the TreeView, so just treating it as a CustomControl
won't work, as I need access to Treeview
's events, etc.