Solved

How to use a TreeView control in VBA

Posted on 2004-04-20
5
687 Views
Last Modified: 2012-05-04

 Just need simple instructions.
       I'm using Excel 2000 and have a form with a new TreeView control.
 In help it says to go to Properties window to Nodes, and add in Nodes.
      I don't see nodes in property window of the TreeView Control, though I see Sample Nodes
 on the Control itself.
      Anyhow, I need a VBA code to add few Parent lines and 5 child lines to each parent.

     Thanks.
0
Comment
Question by:LenkaL
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
sebastienm earned 50 total points
ID: 10872272
LenkaL,

from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cmctl198/html/vbpronodesx.asp
Say your treeview control is named tv1:

   With tv1
      With .Nodes
         .Add , , "R", "Root"
         .Add "R", tvwChild, "C1", "Child 1"
         .Add "R", tvwChild, "C2", "Child 2"
         .Add "R", tvwChild, "C3", "Child 3"
         .Add "R", tvwChild, "C4", "Child 4"
         tv1.Nodes(.Count).EnsureVisible
      End With
      .Style = tvwTreelinesText ' Style 4.
   End With

Other sources of code and doc, but maybe you have already looked at that:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cmctl198/html/vbpronodes.asp

Regards,
Sébastien
0
 

Author Comment

by:LenkaL
ID: 10882552

 Thanks,
 Will try it.
 
0
 
LVL 16

Expert Comment

by:sebastienm
ID: 12092762
Hi LenkaL,
This post has been open for quite a while.
Did the above comment helped you?

Regards,
Sebastien
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had the experience that you had to follow 10 steps over and over again every time when you need to nicely forward an important email to your manager? Fear no more! With the help of the Quick Steps feature in Outlook 2010, your old chor…
Introduction Perhaps more familiar to developers who primarily use VBScript than to developers who tend to work only with Microsoft Office and Visual Basic for Applications (VBA), the Dictionary is a powerful and versatile class, and is useful …
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now