?
Solved

List files and folders in Access Database

Posted on 2013-12-21
1
Medium Priority
?
449 Views
Last Modified: 2013-12-22
I'm trying to make a list of all my files and folders on my server into 2 access tables. One for all my files, and one for all my folders so I can use it as a search engine from a list box. Does anyone know how I could write the vba code to list the following info of my files and folders?

Directory
File Name
File Size
Last Modified
File Extension
File Path
File Created Date/TimeFile Owner?
File Accessed Last Date/Time
0
Comment
Question by:Lawrence Salvucci
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 39734255
I have the important snippet below, and there is a full article on reading all the folders and files https://blogs.technet.com/b/heyscriptingguy/archive/2004/10/20/how-can-i-get-a-list-of-all-the-files-in-a-folder-and-its-subfolders.aspx

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\Scripts"

Set objFolder = objFSO.GetFolder(objStartFolder)
Wscript.Echo objFolder.Path
Set colFiles = objFolder.Files
For Each objFile in colFiles
    Wscript.Echo objFile.Name
Next
Wscript.Echo

ShowSubfolders objFSO.GetFolder(objStartFolder)

Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
        Wscript.Echo Subfolder.Path
        Set objFolder = objFSO.GetFolder(Subfolder.Path)
        Set colFiles = objFolder.Files
        For Each objFile in colFiles
            Wscript.Echo objFile.Name
        Next
        Wscript.Echo
        ShowSubFolders Subfolder
    Next
End Sub

Open in new window


What you would want to do is create your insert code in the for next statement to echo each individual file
For Each objFile in colFiles
    '** Wscript.Echo objFile.Name
     ' Place your insert script here
Next

Open in new window


From the list of properties http://msdn.microsoft.com/en-us/library/ea5ht6ax(v=vs.84).aspx you can choose what information you want to enter to your db.  The size property for instance http://msdn.microsoft.com/en-us/library/2d66skaf(v=vs.84).aspx is object.size  In the example above, you would use objFile.size.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

770 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