PublicFunction funFindDirectory(ByVal strDir As String,Optional vMode As Long =vbDirectory) As Integer Dim vFileNames As String Dim vLoop As Integer Dim vFileAttr As FILEATTRIB varFileCount = 0 varDirCount = 0 On Error GoTo lopErr If strDir = "" Then strDir = varCurrentPath End If If Right(Trim(strDir),1) <>"\" Then strDir = Trim(strDir) &"\" End If strDir = UCase(strDir) vFileNames = Dir(strDir,vMode) ReDim Preserve vFiles(11) ReDim Preserve vDirectories(11) Err.Clear Do While vFileNames <>"" varCurrentPath = strDir If vFileNames <>"." And vFileNames<>".." Then If (GetAttr(strDir&vFileNames) And vbDirectory) = vbDirectory Then If varDirCount Mod10 = 0 Then ReDimPreserve vDirectories(varDirCount + 10) DoEvents End If funGetFileAttribstrDir &vFileNames,vDirectories(varDirCount) varDirCount =varDirCount + 1 Else If varFileCountMod 10 = 0 Then ReDimPreserve vFiles(varFileCount + 10) DoEvents End If funGetFileAttribstrDir &vFileNames,vFiles(varFileCount) varFileCount =varFileCount + 1 End If End If lopErr: vFileNames = Dir(,vbAlias) Loop funQuickSortFile vDirectories(),varDirCount - 1 funQuickSortFile vFiles(),varFileCount - 1 Exit Function 'vErrorMessage = "File Not Found." End Function