Solved

Read and load File names and date modified into a table from a FOLDER

Posted on 2016-08-17
7
44 Views
Last Modified: 2016-08-18
In access vba  - I would like to go to a specific folder (No sub folders) and grab a list of file names and their date modified and date created and put them in a table in 3 columns - [Filename] [DateMod] [DateCreate]  -  any ideas?
I use  
       string = Dir(path & "*.*", vbnormal)
to get filenames all the time but how do u get the dates and other attributes and load them in a table?
0
Comment
Question by:Stephen Roesner
[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
7 Comments
 
LVL 75
ID: 41760316
I just have a moment, but you can easily do this with the File System Object.
If you set a Reference to the VB Scripting Object ... you will have full intellisense.
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
ID: 41760391
FilesystemObject as @mx said is your friend


Dim fs As Object
Dim myfile As Object
Dim myfolder As Object
dim mystring as string
Set fs = CreateObject("Scripting.FileSystemObject")
mystring  = "SomeValidPathToAfolder"
Set myfolder = fs.GetFolder(mystring))
For Each myfile In myfolder.Files
    Msgbox myfile.Path
    msgbox myfile.Name
    msgbox myfile.datecreated
    msgbox Myfile.DateLastModified
Next myfile

replace the msgbox's with good recordset code and you are there.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 41760416
Of course, you would add rows into your table instead of msgbox
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 75
ID: 41760423
Nick already mentioned that "replace the msgbox's with good recordset code and you are there."

:-)
0
 

Author Closing Comment

by:Stephen Roesner
ID: 41761586
great code got it working perfectly thanks a lot
0
 
LVL 26

Expert Comment

by:Nick67
ID: 41761603
Excellent!
0
 
LVL 75
ID: 41761776
"as @mx said "
!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

728 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