0

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.

Kai
  • 2,050
  • 8
  • 28
  • 46

1 Answers1

0

A bit more digging, this answer on another question seems to have worked:

Dim tvw As TreeView
Set tvw = Me.MyTreeView.Object
Community
  • 1
  • 1
Kai
  • 2,050
  • 8
  • 28
  • 46