Solved

Date File (Document) Created

Posted on 2011-09-13
6
219 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

820 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