ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   dir (https://www.excelbanter.com/excel-programming/293376-dir.html)

seeker53

dir
 
I have specified a directory path and a variable is populated for the first file. When I try to get the next file in the directory by useing a = Dir a is populated with "". This would indicate that all files have been seen but there are 8 more files in the directory that have not been touched. Why would dir give a ""

seeker53

JE McGimpsey

dir
 
Using a = Dir a asks for a second file with the same name. For
subsequent files, use a = Dir.


In article ,
"seeker53" wrote:

I have specified a directory path and a variable is populated for the first
file. When I try to get the next file in the directory by useing a = Dir a
is populated with "". This would indicate that all files have been seen but
there are 8 more files in the directory that have not been touched. Why
would dir give a ""?

seeker53


seeker52[_2_]

dir
 
Yes I would agree but when I use a = Dir then a is populated with ""
seeker53

JE McGimpsey wrote in message ...
Using a = Dir a asks for a second file with the same name. For
subsequent files, use a = Dir.


In article ,
"seeker53" wrote:

I have specified a directory path and a variable is populated for the first
file. When I try to get the next file in the directory by useing a = Dir a
is populated with "". This would indicate that all files have been seen but
there are 8 more files in the directory that have not been touched. Why
would dir give a ""?

seeker53


Dave Peterson[_3_]

dir
 
This kind of thing works ok for me:

Option Explicit
Sub testme01()

Application.ScreenUpdating = False

Dim myFiles() As String
Dim fCtr As Long
Dim myFile As String
Dim myPath As String

'change to point at the folder to check
myPath = "c:\my documents\excel\test"
If Right(myPath, 1) < "\" Then
myPath = myPath & "\"
End If

myFile = Dir(myPath & "*.xls")
If myFile = "" Then
MsgBox "no files found"
Exit Sub
End If

'get the list of files
fCtr = 0
Do While myFile < ""
fCtr = fCtr + 1
ReDim Preserve myFiles(1 To fCtr)
myFiles(fCtr) = myFile
myFile = Dir()
Loop

If fCtr 0 Then
For fCtr = LBound(myFiles) To UBound(myFiles)
'do something with mypath & myfiles(fctr)
Next fCtr
End If

Application.ScreenUpdating = True

End Sub



seeker52 wrote:

Yes I would agree but when I use a = Dir then a is populated with ""
seeker53

JE McGimpsey wrote in message ...
Using a = Dir a asks for a second file with the same name. For
subsequent files, use a = Dir.


In article ,
"seeker53" wrote:

I have specified a directory path and a variable is populated for the first
file. When I try to get the next file in the directory by useing a = Dir a
is populated with "". This would indicate that all files have been seen but
there are 8 more files in the directory that have not been touched. Why
would dir give a ""?

seeker53


--

Dave Peterson



All times are GMT +1. The time now is 11:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com