Solved

Date File (Document) Created

Posted on 2011-09-13
6
238 Views
Last Modified: 2012-05-12
I am looking for code tho return the Date Created property of a File (Document) using the File SystemObject

I am using the following code which I got in part from Capricorn1 and which returns the FileName.  I need to also get DateCreated:

Sub GetFileSpecs()
Dim strPath As String, strFile As String
Dim objFSO, objFdr, objDate As Object

strPath = "G:\DocumentScan\"
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   Set objFdr = objFSO.getfolder(strPath)
        strFile = Dir(strPath & "\*.*")

       ********* How do I get strDateCreated  ***********  ????

        Do Until strFile = ""
                Call AddToTable(strFile)
       Loop
End Sub

Sub AddToTable(strFile As String)
Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblDocumentsScanned")
With rst
    .AddNew
    !PDF_Name = strFile

    !PDF_DateCreated  = strDateCreated *********How do I get this String Variable ********** ?????

   .Update
End With

Exit Sub
0
Comment
Question by:Biggles1
[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
  • 4
6 Comments
 

Author Comment

by:Biggles1
ID: 36527842
I would appreciate your help.

Biggles1
0
 
LVL 77

Expert Comment

by:peter57r
ID: 36528005
objFSO.GetFile(strPath & "\" & strFile).DateCreated
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 36528538
Please credit to peter57r. your code should look like below.

Sub GetFileSpecs()
Dim strPath As String, strFile As String
Dim objFSO, objFdr, strDateCreated  As String

strPath = "G:\DocumentScan\"
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   Set objFdr = objFSO.getfolder(strPath)
        strFile = Dir(strPath & "\*.*")
strDateCreated = objFSO.GetFile(strPath & "\" & strFile).DateCreated
 

        Do Until strFile = ""
                Call AddToTable(strFile)
       Loop
End Sub

Sub AddToTable(strFile As String)
Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblDocumentsScanned")
With rst
    .AddNew
    !PDF_Name = strFile

    !PDF_DateCreated  = strDateCreated

   .Update
End With

Exit Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Biggles1
ID: 36535694
I tried this but the expression

strDateCreated = objFSO.GetFile(strPath & "\" & strFile).DateCreated

returns the date when the FOLDER (ie strPath) containing the files was created not the date of each file (strFile)

Any suggestions?
0
 

Accepted Solution

by:
Biggles1 earned 0 total points
ID: 37800240
The code does not accurately return the date created for some reason.
0
 

Author Closing Comment

by:Biggles1
ID: 37820803
I had to abandon the issue.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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 …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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