ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   TreeView in Excel VBA (https://www.excelbanter.com/excel-discussion-misc-queries/117180-treeview-excel-vba.html)

[email protected]

TreeView in Excel VBA
 
Is there any way to show the list that I have on a spreadsheet (see
image) on a TreeView Control using Excel VBA?

http://img135.imageshack.us/img135/6...enprintiv2.png

It is nothing but a list of folders gotten from somewhere using the
shell command and each folder put into 1 column of the Excel. I
basically want that structure to be shown on a User form with the
appropriate structure maintained...thought it may be possible using
Treeview? I have never used Treeview earlier, hence I have no idea how
to use it...any pointers will be greatly appreciated.

Thanks much!
Satish


Andy Pope

TreeView in Excel VBA
 
Hi,

You should find Colo's explanation helpful.
http://puremis.net/excel/code/080.shtml

Cheers
Andy

wrote:
Is there any way to show the list that I have on a spreadsheet (see
image) on a TreeView Control using Excel VBA?

http://img135.imageshack.us/img135/6...enprintiv2.png

It is nothing but a list of folders gotten from somewhere using the
shell command and each folder put into 1 column of the Excel. I
basically want that structure to be shown on a User form with the
appropriate structure maintained...thought it may be possible using
Treeview? I have never used Treeview earlier, hence I have no idea how
to use it...any pointers will be greatly appreciated.

Thanks much!
Satish


Satish

TreeView in Excel VBA
 
Hi Andy

Thanks for the link...it was certainly very helpful. My requirement is
a bit different...but it will help me at least get started...Here is my
exact requirement:

I want the list of folders to be displayed to the user (which I think I
can work out from the sample example provided in your link)... But I
want something more...

I want the user to be able to delete/add/modify folders (nodes in this
case). Something like the explorer in Windows, where if a user deletes
a folder (node) all sub-folders (nodes within that node) must be
deleted...

Do let me know in case anyone has worked on something like this...
thanks for reading...

-Satish

Andy Pope wrote:
Hi,

You should find Colo's explanation helpful.
http://puremis.net/excel/code/080.shtml

Cheers
Andy

wrote:
Is there any way to show the list that I have on a spreadsheet (see
image) on a TreeView Control using Excel VBA?

http://img135.imageshack.us/img135/6...enprintiv2.png

It is nothing but a list of folders gotten from somewhere using the
shell command and each folder put into 1 column of the Excel. I
basically want that structure to be shown on a User form with the
appropriate structure maintained...thought it may be possible using
Treeview? I have never used Treeview earlier, hence I have no idea how
to use it...any pointers will be greatly appreciated.

Thanks much!
Satish



Andy Pope

TreeView in Excel VBA
 
You just need to know which node is selected and then remove it.

Private Sub TreeView1_KeyDown(KeyCode As Integer, _
ByVal Shift As Integer)

Dim nodTemp As Node

If KeyCode = vbKeyDelete Then
Set nodTemp = TreeView1.SelectedItem
If MsgBox("Are you sure you want to delete " & _
nodTemp.Text, vbYesNo Or vbQuestion) = vbYes Then
TreeView1.Nodes.Remove nodTemp.Index
End If
End If

End Sub

Cheers
Andy

Satish wrote:
Hi Andy

Thanks for the link...it was certainly very helpful. My requirement is
a bit different...but it will help me at least get started...Here is my
exact requirement:

I want the list of folders to be displayed to the user (which I think I
can work out from the sample example provided in your link)... But I
want something more...

I want the user to be able to delete/add/modify folders (nodes in this
case). Something like the explorer in Windows, where if a user deletes
a folder (node) all sub-folders (nodes within that node) must be
deleted...

Do let me know in case anyone has worked on something like this...
thanks for reading...

-Satish

Andy Pope wrote:

Hi,

You should find Colo's explanation helpful.
http://puremis.net/excel/code/080.shtml

Cheers
Andy

wrote:

Is there any way to show the list that I have on a spreadsheet (see
image) on a TreeView Control using Excel VBA?

http://img135.imageshack.us/img135/6...enprintiv2.png

It is nothing but a list of folders gotten from somewhere using the
shell command and each folder put into 1 column of the Excel. I
basically want that structure to be shown on a User form with the
appropriate structure maintained...thought it may be possible using
Treeview? I have never used Treeview earlier, hence I have no idea how
to use it...any pointers will be greatly appreciated.

Thanks much!
Satish




Satish

TreeView in Excel VBA
 
Thanx Andy!

Andy Pope wrote:
You just need to know which node is selected and then remove it.

Private Sub TreeView1_KeyDown(KeyCode As Integer, _
ByVal Shift As Integer)

Dim nodTemp As Node

If KeyCode = vbKeyDelete Then
Set nodTemp = TreeView1.SelectedItem
If MsgBox("Are you sure you want to delete " & _
nodTemp.Text, vbYesNo Or vbQuestion) = vbYes Then
TreeView1.Nodes.Remove nodTemp.Index
End If
End If

End Sub

Cheers
Andy

Satish wrote:
Hi Andy

Thanks for the link...it was certainly very helpful. My requirement is
a bit different...but it will help me at least get started...Here is my
exact requirement:

I want the list of folders to be displayed to the user (which I think I
can work out from the sample example provided in your link)... But I
want something more...

I want the user to be able to delete/add/modify folders (nodes in this
case). Something like the explorer in Windows, where if a user deletes
a folder (node) all sub-folders (nodes within that node) must be
deleted...

Do let me know in case anyone has worked on something like this...
thanks for reading...

-Satish

Andy Pope wrote:

Hi,

You should find Colo's explanation helpful.
http://puremis.net/excel/code/080.shtml

Cheers
Andy

wrote:

Is there any way to show the list that I have on a spreadsheet (see
image) on a TreeView Control using Excel VBA?

http://img135.imageshack.us/img135/6...enprintiv2.png

It is nothing but a list of folders gotten from somewhere using the
shell command and each folder put into 1 column of the Excel. I
basically want that structure to be shown on a User form with the
appropriate structure maintained...thought it may be possible using
Treeview? I have never used Treeview earlier, hence I have no idea how
to use it...any pointers will be greatly appreciated.

Thanks much!
Satish






All times are GMT +1. The time now is 11:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com