Hi there,
I am trying to get the value (or text) of the Node when I double click on the treeView. So far no luck. Can you help to write a code in VBA?
I tried this but it does not work:
Private Sub treeView1_DblClick() MsgBox Node.Text End Sub
Hi there,
I am trying to get the value (or text) of the Node when I double click on the treeView. So far no luck. Can you help to write a code in VBA?
I tried this but it does not work:
Private Sub treeView1_DblClick() MsgBox Node.Text End Sub
Try the NodeClick event instead.
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node) Me.Caption = Node.Text End Sub
Jacob,
I tryed this but this is what I get:
Copile Error:
Procedure declaration does not match description of event or procedure have the same name.
Can you post an attachment with your workbook?
Check your code to make sure that there are no subs with the same name.
Also to be sure that the code is correct for your version on Excel. Select TreeView1 from the left drop down on the Code Window in the VBE. And select NodeClick from the right drop down. The correct names for the sub and the arguments will be written in for you.
You can download a TreeView Control example here.
Strange, but that is exactly what I was doing. Still does not work. There is no other procedures with the same name.
Is there a way to attach a workbook with the code?
But your example works for one click. I need it working on double click.
Click on "Post Reply" and scroll down to where it says "Manage Attachments". You need to zip the workbook first then you can upload it.Originally Posted by Kaizer
Ok, I think I understand what you want to do now. Try this:Originally Posted by Kaizer
Option Explicit Dim NodeValue As String Private Sub TreeView1_DblClick() Me.Caption = NodeValue End Sub Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node) NodeValue = Node.Text End Sub
Jacob,
Thank you. It works. I guess there is no need to attach the file.
You're Welcome
Take Care