Solved

Date File (Document) Created

Posted on 2011-09-13
6
230 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

739 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