Problem with DIR

S

SamMy

Looping thru directory, doing something to the files in there. The problem is
that there will allways be one file which is not processed. Ie. when there
are only one file left on directory, DIR is empty. Why so?

Sub test()
ChangeFileOpenDirectory "C:\test\txt\"
Dir (activedirectory & "*.txt")
fName = Dir
While tiedosto <> ""
Documents.Open FileName:=fName
'''' do something to the file
ActiveDocument.Close
Kill fName
Dir (activedirectory & "*.txt")
fName = Dir
Wend
End Sub
 
J

Jezebel

Once you've called DIR() with an argument, you then get further matches by
calling it with NO argument --

fName = Dir (activedirectory & "*.txt")
Do until len(fName) = 0
... do whatever
fName = Dir
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top