Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Date File (Document) Created

Posted on 2011-09-13
6
Medium Priority
?
242 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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

688 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