lkelsen
05-14-2015, 03:42 PM
Hey team,
Fist post on VBA Express so here goes.
The following code successfully populates my TreeView object "tvProjects" on my userform with Parent nodes which are generated from folder names within a specified window directory:
Private Sub UserForm_Initialize()
Dim tvsPath As String
'TreeView Function
tvsPath = dir("I:\02 Clients\" & Range("Q1") & "\Projects\" & Range("Q2") & "\*", vbDirectory)
While tvsPath <> ""
tvProjects.Nodes.Add Text:=tvsPath
tvsPath = dir
Wend
End SubMy issue is, I need to then add all sub-folders within each folder inside the windows directory to each relevant parent node as it would look in a windows explorer directory tree.
I Have searched for this solution on this board and all over the internet but no success in finding a solution. I cant even add a test node to the parent directory when trying to use the parent nodes text or key value etc.
I hope this all makes sense, I am pretty novice with VBA programming.
Im using windows 7
VBA 7.1
VBA Knowledge: Beginner
I only have Microsoft Treeview Control, version 5.0 (SP2) installed on my machine and i believe on all other machines in the office.
Cheers,
Luke Kelsen
Fist post on VBA Express so here goes.
The following code successfully populates my TreeView object "tvProjects" on my userform with Parent nodes which are generated from folder names within a specified window directory:
Private Sub UserForm_Initialize()
Dim tvsPath As String
'TreeView Function
tvsPath = dir("I:\02 Clients\" & Range("Q1") & "\Projects\" & Range("Q2") & "\*", vbDirectory)
While tvsPath <> ""
tvProjects.Nodes.Add Text:=tvsPath
tvsPath = dir
Wend
End SubMy issue is, I need to then add all sub-folders within each folder inside the windows directory to each relevant parent node as it would look in a windows explorer directory tree.
I Have searched for this solution on this board and all over the internet but no success in finding a solution. I cant even add a test node to the parent directory when trying to use the parent nodes text or key value etc.
I hope this all makes sense, I am pretty novice with VBA programming.
Im using windows 7
VBA 7.1
VBA Knowledge: Beginner
I only have Microsoft Treeview Control, version 5.0 (SP2) installed on my machine and i believe on all other machines in the office.
Cheers,
Luke Kelsen