Code to get all the mdb files in a folder

Posted on 2006-05-02
Last Modified: 2010-05-01
can someone give me a vb code that i can insert into macro of excel vba. This code should give the names of all the mdb files inside a folder..

Summary: code to return the path and name of mdb files inside a folder at certain path.
Question by:Aiysha
    LVL 142

    Accepted Solution

    dim fso as object
    dim folder as object
    dim file as object
    set fso = createobject("scripting.Filesystemobject")
    set folder = fso.GetFolder("C:\yourfolder\")
    for each file in folder.files
      if ucase( like "*.MDB" then
         debug.print file.path,
      end if

    Author Comment

    where do I see the results?
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    in the debug window.
    instead of  debug.print you can do other things with the file object's properties...

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now