能不能改成四级显示文件夹或n级显示文件
本帖最后由 bcrun 于 2013-05-04 18:52:33 编辑
Sub TreeviewAddNode(vDir As Variant, skeyWord As String)
'Const a = "\视窗文件"
Dim d, F, d1, ubDir
Dim sPath As String, tempArr, tempArr1
sPath = App.Path
On Error Resume Next
With TreeView1.Nodes
.Clear
.Add , , "请您选择文件", "请您选择文件"
.Item("请您选择文件").Expanded = True
For Each d In vDir
.Add "请您选择文件", tvwChild, d, d
tempArr = GetFile(sPath & "" & d & "")
For Each F In tempArr
If InStr(F, skeyWord) > 0 Then .Add d, tvwChild, d & F, F
Next
Err.Clear
tempArr = GetSubDir(sPath & "" & d & "")
ubDir = UBound(tempArr)
If Err.Number <> 0 Then
Err.Clear
Else
For Each d1 In tempArr
.Add d, tvwChild, d & "" & d1, d1
tempArr1 = GetFile(sPath & "" & d & "" & d1 & "")
For Each F In tempArr1
If InStr(F, skeyWord) > 0 Then .Add d & "" & d1, tvwChild, d & "" & d1 & F, F
Next
Next
End If
Next
End With
End Sub