Selection.Delete
ActiveDocument.Save
End If
Next
End Sub
Public Function TreeSearch(ByVal strPath As String, ByVal strFileSpec As String, strFiles() As String) As Long
Static lFiles As Long
Dim lTemp As Long
Dim lIndex As Long
Dim strDir As String
Dim strSubDirs() As String
If Right(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
strDir = Dir(strPath & strFileSpec)
Do While Len(strDir)
lFiles = lFiles + 1
ReDim Preserve strFiles(1 To lFiles)
strFiles(lFiles) = strPath & strDir
strDir = Dir
Loop
lIndex = 0
strDir = Dir(strPath & "*.*", vbDirectory)
Do While Len(strDir)
lPos = Len(strDir)
If Right(strDir, lPos) <> "." And Right(strDir, lPos) <> ".." Then
If GetAttr(strPath & strDir) And vbDirectory Then
lIndex = lIndex + 1
ReDim Preserve strSubDirs(1 To lIndex)
strSubDirs(lIndex) = strPath & strDir & "\"
End If
End If
strDir = Dir
Loop
For lTemp = 1 To lIndex
Call TreeSearch(strSubDirs(lTemp), strFileSpec, strFiles())
Next lTemp
TreeSearch = lFiles
End Function
文章来源于领测软件测试网 https://www.ltesting.net/