Results 1 to 3 of 3
  1. #1
    dumbledown is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    46

    Smile count number of file names within a folder containing


    Hi,
    I have a folder (called C:\FolderOfInterest)
    In it are loads of files including FileOfInterest1.txt, FileOfInterest2.csv and FileOfInterestExtra.other
    Can anyone point me to code where I can retrieve a value for counting how many files are named including "FileOfInterest" within the folder; FileCounts=3 in this case.
    Hope that makes sense
    Many thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    In a loop structure read the name of each file in the folder and compare to the criteria. Increment a counter variable for each match. Review http://www.freevbcode.com/ShowCode.asp?ID=1487
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    dumbledown is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    46
    Thanks for the response, I found this code that worked great


    Sub
    Demo()
    MsgBox FileCountA("C:\temp\")
    End Sub

    Function
    FileCountA(Path As String) As Long Dim
    strTemp As String Dim
    lngCount As Long
    strTemp = Dir(Path & "*.*")
    Do While strTemp <> "" lngCount = lngCount + 1
    strTemp = Dir
    Loop FileCountA = lngCount
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to copy a file from one folder to another in vba
    By pkstormy in forum Code Repository
    Replies: 2
    Last Post: 09-20-2012, 05:32 PM
  2. Replies: 21
    Last Post: 01-24-2012, 06:21 PM
  3. Replies: 6
    Last Post: 07-25-2011, 01:54 PM
  4. folder locked after attaching a file
    By jimg972 in forum Access
    Replies: 0
    Last Post: 05-25-2011, 06:21 PM
  5. Copy file to folder
    By tpcervelo in forum Programming
    Replies: 11
    Last Post: 08-31-2010, 10:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums