#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"