Edward S Zuris
edzedz at comcast.net
Thu Jun 26 21:33:11 CDT 2008
If you ignore the constant for word documents you should be able to make the following code do what you want it to. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = Const cFileTypeWordDocuments = 3 Const cmsoSortOrderAscending = 1 Const cmsoSortOrderDescending = 2 Const cmsoSortByFileName = 1 Const cmsoSortBySize = 2 Const cmsoSortByFileType = 3 Const cmsoSortByLastModified = 4 . . . ' ***************************************************** ' ***************************************************** ' Add Wild Card ' zPrefix = zPrefix & "*" ' **************************************************** ' Parameter Input path for Job Boiller documents ' szPath = "" szPath = Trim$(zzzLastBoil(17, " ", " ", " ") & " ") If Len(szPath) > 5 Then zJPPath = "" zJPPath = Trim$(szPath & " ") End If ' ***************************************************** ' Setup the Boiler Plate file search ' With Application.FileSearch .NewSearch .LookIn = zJPPath .SearchSubFolders = True .FileName = zPrefix .FileType = cFileTypeWordDocuments End With ' ***************************************************** ' Count the Boiler Plate files ' With Application.FileSearch If .Execute(cmsoSortByFileName, cmsoSortOrderAscending, True) <= 0 Then MsgBox "There were no Boiler Plate Word files found." GoTo zzJPCollect1_End End If lFileKnt = 0 lFileKnt = .FoundFiles.Count = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Darren D Sent: Thursday, June 26, 2008 5:07 PM To: 'Access Developers discussion and problem solving' Subject: [AccessD] A2003:Counting Files in a folder Hi team Does anyone have an example of counting how many files there are of a particular type in a folder? EG I want to count all the PDF, TXT and XML files in 3 corresponding folders EG the folders are named for the file type they hold Folder 1 = \\OurServer\OurClient\Files\XML\*.xml Folder 2 = \\OurServer\OurClient\Files\PDF\*.pdf Folder 3 = \\OurServer\OurClient\Files\TXT\*.txt The Air code I have is See how many file types there are for client X (In the Example above there are 3 but it may be 2 or 1 even 4) So in the example above using 3 file types Start a loop for file types and count the number of files in that folder type Loop 1 = xml See how many files are in folder .\XML Report the file count move to next file type Loop 2 will = pdf See how many files are in folder .\PDF Report the file count move to next file type Loop 3 will = txt See how many files are in folder .\txt Report the file count move to next file type Then exit the loop Many thanks in advance Darren -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com