Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
TreeView1
Hi I have been trying to load folder and sub folders and file, I can first
level folders but having problem trying to get second etc. If anybody could it would be much appreciated. Charles |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
TreeView1
Try code like the following in the userform that contains the TreeView:
Private Sub CommandButton1_Click() Dim TopFolderStr As String Dim TopFolder As Scripting.Folder Dim FSO As Scripting.FileSystemObject Dim TopNode As Node TopFolderStr = "C:\TopLevelFolder" Set FSO = New Scripting.FileSystemObject Set TopFolder = FSO.GetFolder(TopFolderStr) Set TopNode = UserForm1.TreeView1.Nodes.Add(Text:=TopFolder.Name ) DoFolder FSO, UserForm1.TreeView1, TopFolder, TopNode End Sub Private Sub DoFolder(FSO As Scripting.FileSystemObject, _ TVX As TreeView, WhatFolder As Scripting.Folder, _ WhatFolderNode As Node) Dim FF As Scripting.Folder Dim F As Scripting.File Dim FFNode As Node Dim FNode As Node Dim SubFF As Scripting.Folder For Each FF In WhatFolder.SubFolders Set FFNode = TVX.Nodes.Add(WhatFolderNode, tvwChild, , FF.Name) For Each F In FF.Files Set FNode = TVX.Nodes.Add(FFNode, tvwChild, , F.Name) Next F For Each SubFF In WhatFolder.SubFolders DoFolder FSO, TVX, FF, FFNode Next SubFF Next FF End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting www.cpearson.com (email on the web site) "vqthomf" wrote in message ... Hi I have been trying to load folder and sub folders and file, I can first level folders but having problem trying to get second etc. If anybody could it would be much appreciated. Charles |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
TreeView1
Thanks Chip I do have one question when I run the code I get duplicate
Folders [6 times] I have stepped through the code but can't see where it's doing it? Regards Charles PS I like the code I was using different function to try and do the same thing. "vqthomf" wrote: Hi I have been trying to load folder and sub folders and file, I can first level folders but having problem trying to get second etc. If anybody could it would be much appreciated. Charles |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
TreeView1
Thamks Chip I have work out what was caused the Dups I removed For Each SubFF
In WhatFolder.SubFolders and it was okay Regards Charles "vqthomf" wrote: Thanks Chip I do have one question when I run the code I get duplicate Folders [6 times] I have stepped through the code but can't see where it's doing it? Regards Charles PS I like the code I was using different function to try and do the same thing. "vqthomf" wrote: Hi I have been trying to load folder and sub folders and file, I can first level folders but having problem trying to get second etc. If anybody could it would be much appreciated. Charles |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
TreeView1
Thamks Chip I have work out what was caused the Dups I removed For Each
SubFF In WhatFolder.SubFolders and it was okay You need that code if you are looping through an arbitrary level of nest folders and files. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting www.cpearson.com (email on the web site) "vqthomf" wrote in message ... Thamks Chip I have work out what was caused the Dups I removed For Each SubFF In WhatFolder.SubFolders and it was okay Regards Charles "vqthomf" wrote: Thanks Chip I do have one question when I run the code I get duplicate Folders [6 times] I have stepped through the code but can't see where it's doing it? Regards Charles PS I like the code I was using different function to try and do the same thing. "vqthomf" wrote: Hi I have been trying to load folder and sub folders and file, I can first level folders but having problem trying to get second etc. If anybody could it would be much appreciated. Charles |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|