![]() |
Dir() limited to 48 files?
I have written the following code that opens the files in
a directory, then performs some manipulations, and saves the file: Do While NameOfFile < "" Application.EnableEvents = False Workbooks.Open (CurDir & "\" & NameOfFile) Application.EnableEvents = True .... Workbooks(NameOfFile).Close savechanges:=True NameOfFile = Dir() Loop What puzzles me is that the loop runs 48 times, then stops without reason. Is there some limitation on how many times the dir() command can be run? File 49 is in no way different to the other files. |
Dir() limited to 48 files?
Hi Claude
How many files see this test file in C:\Data Sub Testing() Dim mybook As Workbook Dim Fnum As Long Dim FNames As String Dim MyPath As String Dim SaveDriveDir As String SaveDriveDir = CurDir MyPath = "C:\Data" ChDrive MyPath ChDir MyPath FNames = Dir("*.xls") If Len(FNames) = 0 Then MsgBox "No files in the Directory" ChDrive SaveDriveDir ChDir SaveDriveDir Exit Sub End If Application.ScreenUpdating = False Fnum = 0 Do While FNames < "" Fnum = Fnum + 1 FNames = Dir() Loop ChDrive SaveDriveDir ChDir SaveDriveDir MsgBox Fnum Application.ScreenUpdating = True End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2002 SP-2) www.rondebruin.nl "Claude" wrote in message ... I have written the following code that opens the files in a directory, then performs some manipulations, and saves the file: Do While NameOfFile < "" Application.EnableEvents = False Workbooks.Open (CurDir & "\" & NameOfFile) Application.EnableEvents = True .... Workbooks(NameOfFile).Close savechanges:=True NameOfFile = Dir() Loop What puzzles me is that the loop runs 48 times, then stops without reason. Is there some limitation on how many times the dir() command can be run? File 49 is in no way different to the other files. |
Dir() limited to 48 files?
OK, Excel just crashed, and now its running through till
the end of the directory... This must be due to the sunspot activity... |
All times are GMT +1. The time now is 12:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com