Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    597
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Capture the file names of a specified drive

    Good Morning everyone,

    I need code to capture the file name(s) from a specified drive and append the names to an existing table in Access 2010. Also, a nuance to this code, would determine if the file name already exists in the existing table. If it does, don't append it.

    I think the code will have something to do with GetFileObject function but not certain. Any assistance with code is greatly appreciated.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,192
    Thanks
    201
    Thanked 781 Times in 715 Posts
    Roberta,

    Here's some VBA code written for Excel but should work, with appropriate modification, in Access. Please note not all the variables are declared {dim} because they are Global or Module level variables and declared elsewhere. You should always declare your variables in your code.
    Code:
    '                    +------------------------------+             +----------+
    '--------------------|      bLocate_Files()         |-------------| 03/15/10 |
    '                    +------------------------------+             +----------+
    'Parameters: zPath - A string with the Directory\Path information to search.
    'Returns:    True:  Files found
    '            False: No matching files found.
    
    Function bLocate_Files(zPath As String) As Boolean
    
       iListCntr = 0
       zFileList(iListCntr + 1, 1) = Dir(zPath & "\" & zBaseFName & "*.xls*")
       
       Do While zFileList(iListCntr + 1, 1) <> ""
        iListCntr = iListCntr + 1
        zFileList(iListCntr, 2) = zPath
        zFileList(iListCntr + 1, 1) = Dir()
       Loop    'Loop while there are files in the directory
    
       bLocate_Files = IIf((iListCntr > 0), True, False)
       
    End Function         'bLocate_Files()
    Hope this helps.
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  4. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    597
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks RG, I will give this a try and update then.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •