From: joel on 3 May 2010 11:49 Ooh! I didn't realize last week you were getting a files in a Folder which does have the limit of 1500 files. I don't rememer if the scripting obectject contains the same limits. the problem is with the operating system getting the file names and not an array size limit. The last time I seen this problem was probably 5 years ago. I don't remmeber how I fixed the problem. Private Function AllFiles(ByVal FullPath As String) _ As String() '*************************************************** 'PURPOSE: Returns all files in a folder using 'the FileSystemObject 'PARAMETER: FullPath = FullPath to folder for 'which you want all files 'RETURN VALUE: An array containing a list of 'all file names in FullPath, or a 1-element 'array with an empty string if FullPath 'does not exist or it has no files 'REQUIRES: Reference to Micrsoft Scripting ' Runtime 'EXAMPLE: 'Dim sFiles() as string 'dim lCtr as long 'sFiles = AllFiles("C:\Windows\System") 'For lCtr = 0 to Ubound(sFiles) ' Debug.Print sfiles(lctr) 'Next 'REMARKS: The FileSystemObject does not 'Allow for the use of wild cards (e.g., '*.txt.) If this is what you need, see 'http://wwww.freevbcode.com/ShowCode.asp?ID=1331 '************************************************ Dim oFs As New FileSystemObject Dim sAns() As String Dim oFolder As Folder Dim oFile As File Dim lElement As Long ReDim sAns(0) As String If oFs.FolderExists(FullPath) Then Set oFolder = oFs.GetFolder(FullPath) For Each oFile In oFolder.Files lElement = IIf(sAns(0) = "", 0, lElement + 1) ReDim Preserve sAns(lElement) As String sAns(lElement) = oFile.Name Next End If AllFiles = sAns ErrHandler: Set oFs = Nothing Set oFolder = Nothing Set oFile = Nothing End Function -- joel ------------------------------------------------------------------------ joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229 View this thread: http://www.thecodecage.com/forumz/showthread.php?t=200111 http://www.thecodecage.com/forumz
|
Pages: 1 Prev: Get column of named cell Next: Unknown object in the Project Explorer in VBE |