Solved

Date File (Document) Created

Posted on 2011-09-13
6
189 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
  • 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

10 Experts available now in Live!

Get 1:1 Help Now