Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Courses > Access > Seminars > Email > Lessons >
Back to Email Seminar Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email  
Accessing file inform Lesson 7
Sami Shamma 
             
2 years ago
Good mooring
I would like to get the file creation date from windows from my VBA code. Can I do that?

Many thanks
Kevin Robertson  @Reply  
          
2 years ago
Yes. Here is a function to get the created date.

In Global Module
Public Function ShowFileInfo(filespec) As Date

    Dim fso As Object, f As Object, D As Date
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFile(filespec)
    D = f.DateCreated
    ShowFileInfo = D
    
    Set fso = Nothing
    Set f = Nothing
    
End Function


In Button Click Event
Dim createdDate As Date
    createdDate = ShowFileInfo("Full Path of Your File")
        
    MsgBox "Created: " & createdDate
Sami Shamma OP  @Reply  
             
2 years ago

Sami Shamma OP  @Reply  
             
2 years ago
Hi Kevin

I am getting the wrong date returned from my code!
What am I doing wrong?
Sami Shamma OP  @Reply  
             
2 years ago
Sorry Kevin

It is working correctly. I was looking at the wrong date.

Many thanks again
Kevin Robertson  @Reply  
          
2 years ago
I have tested it on several files and get the correct date. Are you sure it is Date Created that being displayed in File Explorer?
Right click on the file, then click on properties in the context menu.
Kevin Robertson  @Reply  
          
2 years ago
OK. Glad it's working.
Sami Shamma OP  @Reply  
             
2 years ago
Hi Again

What I need is the "Modified" date.
I tried to change the code to read:
       D = f.DateModified
but that did not work

Help!!
Kevin Robertson  @Reply  
          
2 years ago
Almost correct. Use this:
D = f.DateLastModified
Sami Shamma OP  @Reply  
             
2 years ago
Thanks, that worked.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Email Seminar Lessons.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/14/2025 4:30:03 PM. PLT: 1s