Most Valuable Professional


View Jan Karel Pieterse's profile on LinkedIn subscribe to rss feed
Subscribe in a reader

Subscribe to our mailing list

* indicates required

Audit !!!

Check out our RefTreeAnalyser
the ultimate Excel formula auditing tool.

Trainings

Excel VBA Masterclass (English)
Excel VBA for Financials (Dutch)

Third party tools

Speed up your file

FastExcel
The best tool to optimise your Excel model!

Repair your file

Stellar Phoenix Excel Repair
Best tool to repair corrupt Excel sheets and objects
Home > English site > Articles > Treeview control > Examples

An MSForms (all VBA) treeview; Examples

This page displays some examples where our treeview has been used.

RefTreeAnalyser

Our RefTreeAnalyser also implements the treeview control, as you can see here:

Screenshot of RefTreeAnalyser, the ultimate Excel formula auditing tool.

The City Of Amsterdam

The Engineering Desk of the City of Amsterdam has implemented our Treeview in a VBA driven tool which is used by the technical designers of the Engineering desk so their drawings comply with the Dutch CAD standard NLCS. This is what the treeview looks like in their software:

Screenshot of technical drawing tool.

Extended Project Explorer

(by Peter Thornton)

The purpose of this file is to show a few ways how the VBA Treeview can be used in a real life app. The treeview lists projects and modules similar to the VBE's (Visual Basic Editor) Project Explorer, but the branches are extended to list procedures and declarations. These can be double clicked and in turn activated in the VBE.

Other features include routines to search the treeview, return details of the treeview to a sheet to document projects, and more. Please refer to the main demo files for the most recent version of the VBA Treeview.

It looks like this:

Screenshot of Extended Project Explorer.

Access and Word users: please note documentation is included in the main Excel demo.

Download The Extended Project Explorer V1.0 (Updated Dec 04, 2013, downloaded: 2,962times)

Access Archon article

Description: Helen Feddema from Access Watch published an Access Archon article with a sample .accdb database using the Treeview alternative that works in 64-bit Office; also includes a sample .mdb database that uses the native Treeview control.

XER toolkit

The XER Toolkit is an MS Excel based application that can read, display and analyse data from Oracle's Project Management application, Primavera. The toolkit helps to improve the quality of project schedules by providing visibility without the requirement for (expensive) Primavera licences. As an enterprise system, the data within Primavera is hierarchically arranged and so the Treeview developed by JKP has become an integral and essential part of the toolkit's data access functionality. See the video. One of the screens in the tool:

Treeview data selector

Spanish diseases classification list

From Diego Pereira: This treeview loads the International Classification of Diseases in Spanish. By entering a word, a part of a word or a ICD10 code, one can locate matching nodes, highlight them and expand them. The main purpose of this example is to serve as a simple implementation of the Treeview in an Access style.

Download the sample Access accdb database (05 Mar 2014, downloaded 2,306 times)

Treeview showing Spanish Diseases classifications

Sheet navigation tool

Yves Leboutte sent us these screenshots:

Go To sheet: Allows to jump to worksheet < List of countries
Jump to sheet

Go To Item: To jump to 1 item (rows)
Jump to item

Item Selection: Allows to save options to some items in 1 or all childs sheets.
Item selection

Filtered tree

Tiago Costa from EWEN Energy shared a treeview with us which the user can filter. The filtering is implemented quite simple by filtering the table containing the source data for the tree and rebuilding the tree after filtering using the filtered table (in a Worksheet). I particularly like the looks of the form, very "modern UI"-like:

Nice form with filtered tree

Template system

Template system

Your implementation

We're always interested to see how people have implemented the VBA Treeview. So please feel free to send a screenshot with a brief description or relevant details.

 


Comments

Showing last 8 comments of 29 in total (Show All Comments):

 


Comment by: Jan Karel Pieterse (4/22/2016 4:39:18 PM)

Hi Daniel,

The double-click event of a node is currently reserved for going into label edit mode. You can find the event in clsNode:

Private Sub mctlControl_DblClick(ByVal Cancel As MSForms.ReturnBoolean)


To add a double-click event of the treeview to your own project you need a couple of steps, which I have described in a comment on this page:

http://www.jkp-ads.com/Articles/treeview.asp?AllComments=True

Look for this comment:

"Comment by: Jan Karel Pieterse (5/24/2013 12:55:38 PM)"

 


Comment by: Life (6/14/2016 9:39:06 AM)

Hi there

thank you so much for sharing your code and effort
with the world.

I am devlepoing a Ms Access in a Right to Left enviorment,
Thererfore I am wondering whether there is a simple way to define the TreeView as right to left display?

 


Comment by: Jan Karel Pieterse (6/14/2016 10:31:10 AM)

Hi Life,

Wow, that isn't easy in our current implementation. The entire control is indeed designed to be left-to-right.
You'd have to redo all assignments in clsTreeView that contain ".Left = ......." and make them direction sensitive.
Maybe something I can ask you to do? :-P

 


Comment by: Peter Thornton (6/14/2016 2:09:07 PM)

Hi Life,

Indeed not easy, that said nothing is impossible. I suspect the biggest challenge would be catering for variable widths when the scrollbars are implemented for a left-right environment, or do they also automatically switch in right-left?

Otherwise if the entire 'insidewidth' is fixed at design it might be easier, still a fair amount of work though!

 


Comment by: David Bickerton (7/22/2016 5:22:26 PM)

Hi,

I am using MSForms (All VBA) Treeview - it is great so far - thanks for all the help.

I am having issues with SETTING new PARENT NODES within the code ? Example : How can I do this when I have 10 NODES all at Level 0. Then I want one of these Nodes to move to the sibling of one of the others that already exist ? I am assuming I do something like

Set mcTree.Nodes(strKey).ParentNode.Key = "117"

But I am having problems.

Thanks,

David


 


Comment by: Peter Thornton (8/1/2016 3:39:01 PM)

Hi David,

The treeview includes a 'move' method, eg

mcListMove cSource, cDest


..where cSource is the node you want to move and cDest is the new parent.

See "Move" in the documentation in the Excel demo (clsTreeview) if you want to place before or after some node.

 


Comment by: Steven Wade (7/28/2017 3:54:18 PM)

Do you have any code examples that show how to synchronize the data record displayed on an MS Access form based on the value selected in the tree control (subform) on that same page? (similar to how linking master and child fields allows form/subform synchronization)

 


Comment by: Peter Thornton (7/31/2017 8:12:58 AM)

Hi Steven,

To trap the treeview's click event and whatever Access form event traps the selected data record and the events select or activate the reciprical item, something like this:

Private Sub mcTree_Click(cNode As clsNode)
    ' activate associated data record
End Sub

'In the Access form event
k = the KeyOrIndex associated with selected data item

    Set mcTree.ActiveNode = mcTree.Nodes(k)
    mcTree.ScrollToView mcTree.ActiveNode

 


Have a question, comment or suggestion? Then please use this form.

If your question is not directly related to this web page, but rather a more general "How do I do this" Excel question, then I advise you to ask your question here: www.eileenslounge.com.

Please enter your name (required):

Your e-mail address (optional but if you want me to respond it helps!; will not be shown, nor be used to send you unsolicited information):

Your request or comment:

To post VBA code in your comment, use [VB] tags, like this: [VB]Code goes here[/VB].