还是不行啊,运行一会儿就自动关闭CAD了。帮我看看整段程序好吗?
Public Sub AddSupportPath(ByVal Path As String) Dim curSupportPath As Variant Dim i As Integer Dim Support As Boolean
Support = False curSupportPath = Split(ThisDrawing.Application.Preferences.Files, ";")
For i = 0 To UBound(curSupportPath) If StrConv(curSupportPath(i), vbUpperCase) = StrConv(Path, vbUpperCase) Then Support = True Exit For End If Next
If Not Support Then Debug.Print ThisDrawing.Application.Preferences.Files Debug.Print Len(ThisDrawing.Application.Preferences.Files) Debug.Print Path Debug.Print Len(Path) ThisDrawing.Application.Preferences.Files = ThisDrawing.Application.Preferences.Files & ";" & Path 'FrmMain.ListBox1.AddItem Path End If End Sub
'''指定路径下的所有文件夹 Public Function GetAllFolder(ByVal root As String)
Dim fsoSubFolder As Folder Dim astr As String Dim fsoSys As New Scripting.FileSystemObject Dim fsoRootFolder As Folder
Set fsoRootFolder = fsoSys.GetFolder(root) '''添加搜索路径 AddSupportPath (root) For Each fsoSubFolder In fsoRootFolder.SubFolders astr = fsoSubFolder.Path '''添加搜索路径 AddSupportPath (astr) '''递归调用 Call GetAllFolder(astr) Next Set fsoRootFolder = Nothing
End Function |