Adding nodes to treeview

G

Guest

How do you add nodes to a treeview control using VBA for Excel?

I've tried the code for VB6

TreeView1.Nodes.Add "MyFirstNode", tvwChild, ,"MyChildNode"

But it is telling me that tvwChild is not declared...

In Excel VBA the quick help for the Add method shows the arguments:
[relative],[relationship],[key],[text],[image],[selectedimage]

but I can't find any documentation as to what syntax to use for these
arguments.

Does anyone know what the syntax for these arguments is for Excel 2002 VBA?
Also, do I need to set a reference to something?

Thanks,
John
 
G

Guest

You will need to add a Treeview Control to the Toolbox.

Tools -> Additional Controls -> Microsoft Treeview Control

I haven't used the treeview in VBA but it should be similar to VB6

Hope this Helps...
 
G

Guest

Yeah I've already added the control to the tool box and to my userform.

You'd think it would be similar to VB6. I've tried using VB6 syntax but
I'm getting "variable not defined" errors.



Jim Thomlinson said:
You will need to add a Treeview Control to the Toolbox.

Tools -> Additional Controls -> Microsoft Treeview Control

I haven't used the treeview in VBA but it should be similar to VB6

Hope this Helps...

John said:
How do you add nodes to a treeview control using VBA for Excel?

I've tried the code for VB6

TreeView1.Nodes.Add "MyFirstNode", tvwChild, ,"MyChildNode"

But it is telling me that tvwChild is not declared...

In Excel VBA the quick help for the Add method shows the arguments:
[relative],[relationship],[key],[text],[image],[selectedimage]

but I can't find any documentation as to what syntax to use for these
arguments.

Does anyone know what the syntax for these arguments is for Excel 2002 VBA?
Also, do I need to set a reference to something?

Thanks,
John
 
C

Chip Pearson

John,

Ensure that you have a reference (VBA Tools menu, References) set
to Microsoft Windows Common Controls.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



John said:
Yeah I've already added the control to the tool box and to my
userform.

You'd think it would be similar to VB6. I've tried using VB6
syntax but
I'm getting "variable not defined" errors.



Jim Thomlinson said:
You will need to add a Treeview Control to the Toolbox.

Tools -> Additional Controls -> Microsoft Treeview Control

I haven't used the treeview in VBA but it should be similar to
VB6

Hope this Helps...

John said:
How do you add nodes to a treeview control using VBA for
Excel?

I've tried the code for VB6

TreeView1.Nodes.Add "MyFirstNode", tvwChild, ,"MyChildNode"

But it is telling me that tvwChild is not declared...

In Excel VBA the quick help for the Add method shows the
arguments:
[relative],[relationship],[key],[text],[image],[selectedimage]

but I can't find any documentation as to what syntax to use
for these
arguments.

Does anyone know what the syntax for these arguments is for
Excel 2002 VBA?
Also, do I need to set a reference to something?

Thanks,
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top