Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Need help with Treeview control ??

38 views
Skip to first unread message

Dan Thompson

unread,
Dec 9, 2004, 3:23:01 PM12/9/04
to
Well that may be true however I have added The treeview control to my forms
toolbox and have such added the control to my form I am able to refference it
withing Excel VBA code too for example

With Me
Treview1.Nodes.Add(blah blah blah)
end with
but when I add the nodes and run the control on my form nothing happens
I know that this control can be used in a Excel VBA form.
Im just not sure how to get it going has anyone used this control on a Excel
VBA form before that can help me with a small working sample ?

Thanks Dan Thompson

"Tom Ogilvy" wrote:

> http://support.microsoft.com/default.aspx?scid=kb;en-us;244954
> How To Populate a Treeview Control with an XML File
>
> The treeview control is not distributed with microsoft office, so you
> wouldn't expect to find anything about it in the help files for excel.
>
> --
> Regards,
> Tom Ogilvy
>
> "Dan Thompson" <DanTh...@discussions.microsoft.com> wrote in message
> news:36107946-73DA-41C2...@microsoft.com...
> > Hi there I am extreamly frustrated because I have recently discoverd the
> > treeview control but am unable to use it. I have found nothing in the
> Excel
> > VBA help files of use and every search I have done for a example code has
> > been either far to complex or had errors in in it before I edited
> anything.
> > Could someone please help me with a small very very very basic example
> code
> > for populating and using the Treeview control on a vba form.
> >
> > Thanks, Dan
> >
>
>
>

Harald Staff

unread,
Dec 9, 2004, 4:12:26 PM12/9/04
to
Hi Dan

Short explanation of the Blah blah part:

Nodes.Add(Key of parent node, relation to parent node, unique node key, node
text, optional icon to display)

Private Sub UserForm_Initialize()
Dim L1 As Long, L2 As Long
With Me.TreeView1
Dim NodX As Node
Set NodX = .Nodes.Add(, , "Root", "My main node")
Set NodX = Nothing
For L1 = 1 To 6
Set NodX = .Nodes.Add("Root", tvwChild, _
"Sub" & L1, "Child " & L1)
NodX.EnsureVisible
Set NodX = Nothing
For L2 = 1 To 12
Set NodX = .Nodes.Add("Sub" & L1, tvwChild, _
"Sub" & L1 & "sub" & L2, "Grandhild " & L1)
Set NodX = Nothing
Next
Next
End With
End Sub

Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
If Node.Key = "Root" Then
MsgBox "I'm root."
Else
MsgBox "You just clicked " & Node.Key & ", proud child of the great " &
_
Node.Parent.Key
End If
End Sub

HTH. Best wishes Harald

"Dan Thompson" <DanTh...@discussions.microsoft.com> skrev i melding
news:FA061EDF-AF70-482B...@microsoft.com...

Tom Ogilvy

unread,
Dec 9, 2004, 3:09:36 PM12/9/04
to

Dan Thompson

unread,
Dec 9, 2004, 5:25:07 PM12/9/04
to
Thanks Harald
That worked GREAT!
You were a big help, realy apreciate your input.

Dan

Harald Staff

unread,
Dec 9, 2004, 5:54:56 PM12/9/04
to
"Dan Thompson" <DanTh...@discussions.microsoft.com> skrev i melding
news:70091C4A-F8FA-4326...@microsoft.com...

> Thanks Harald
> That worked GREAT!
> You were a big help, realy apreciate your input.

Glad to hear that Dan. Thanks for the feedback.
Best wishes Harald


0 new messages