I have the following sub:

Sub TheTreeview()
 Dim Win: Set Win = FocusedWindow
 If Win.Type <>WtTreeView Then Exit Sub

' Apparently we are in a TreeView:
 Speak Win.Type
 Speak "You are now in a treeview."

 Dim Ctrl: Set Ctrl = Win.Control
 Dim TView: Set TView = Ctrl.TreeView

 speak TreeViewItems.Count
End Sub 'TheTreeview.

I can place my cursor on anything else but a treview, and the sub will simply 
exit. So far, things are alright. 

When I put my cursor on a treview, and run this sub, it sure speaks two lines 
of info:
    22
    You are now in a treeview.
Just what I expected it to.

But then it throws an error on me:
    Object doesn't support this property or method: 'Ctrl.TreeView'

A bit confused. Likely I am missing something, but can't figure exactly what. 
In the documentation of WE, it states under TreeView:
Usage
Use a
TreeView
 object to retrieve information regarding a tree view control. A
TreeView
 object can be obtained from a
Window
 object's
Control
 method when the
Window
 object's
Type
 is
wtTreeView


In my sub, I set an object (Win) from the FocusedWindow. Then another object 
(Ctrl) from that Window object's Control. Isn't that what the documentation 
claims to be the way to go? And from here, I should have been able to retrieve 
the TreeView object. What am I missing?

Thanks for any guidance.

Reply via email to