p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Access VBA (http://p2p.wrox.com/forumdisplay.php?f=80)
-   -   Capturing date from transferred file (http://p2p.wrox.com/showthread.php?t=31486)

Axxess July 14th, 2005 01:49 AM

Capturing date from transferred file
 
Backround:
I use Access to transfer file attachments from Outlook to a certain folder on a server for further processing. That works fine, but I would like to return the "Modified" date of the transferred files to my Access form by the file name list. How can I capture the file dates from the folder?

Thanx in advance.


mmcdonal July 15th, 2005 07:27 AM

Hi,

   This will get you your file DateCreated:

'----------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("C:\data.csv")
stLongDate = objFile.DateCreated
DateArray = Split(stLongDate, " ")
stShortDate = DateArray(0)
WScript.Echo stShortDate
'----------

   objFile.DateCreated is the date and time the file was created. I split it using the space between the date and time to get just the date. I used a file called C:\data.csv that I use for filesystem tests.

   You can use this code in your access code. I am assuming you will know the path to the file you are working with. If so, then capture the path in a variable, and rewrite the code like this:

'----------
Dim stPath As String
stPath = "C:\data.csv"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(stPath)
stLongDate = objFile.DateCreated
DateArray = Split(stLongDate, " ")
stShortDate = DateArray(0)
WScript.Echo stShortDate
'----------

Then just pass stShortDate in your code to addnew to your table.

HTH


mmcdonal

Axxess July 18th, 2005 05:21 AM

Thanx again,

This works like a clockwork. Got one set of problems solved.

Axxess



All times are GMT -4. The time now is 09:59 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.