Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Problem with DIR

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SamMy - 26 Mar 2006 23:58 GMT
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
Jezebel - 27 Mar 2006 07:26 GMT
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

> Looping thru directory, doing something to the files in there. The problem
> is
[quoted text clipped - 14 lines]
>    Wend
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.