getting the date a directory was created

S

Steven Revell

Hi,

I want to be able to find out the data that a directory
was created using VBA. Is it possible?

Thanks for any help,

Steven
 
K

keepitcool

active the Microsoft Scripting Runtime in references

then
Sub DirDate()
Dim fso As New Scripting.FileSystemObject
Dim fld As Scripting.Folder
Set fld = fso.GetFolder("c:\windows")
MsgBox fld.DateCreated
End Sub


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
S

Steven Revell

I get an error "object variable or with variable not set"
at this line:

Set fld = fso.GetFolder("c:\windows")

Cheers for the help,
Steven
 
T

Tom Ogilvy

Did you create a reference to the Microsoft Scripting Runtime in the
Tools=>References portion of the VBE with your workbook as the active
workbook. If not, you need to.
 
T

Tom Ogilvy

This worked if you don't want to create the reference:

Sub DirDate1()
Dim fso As Object
Dim fld As Object
Set fso = CreateObject("Scripting.Filesystemobject")
Set fld = fso.GetFolder("c:\winnt")
MsgBox fld.DateCreated
End Sub

nonetheless, either with a reference or without, I couldn't duplicate your
error message with either verions of the code. If the directory didn't
exist, I got a 76 error (path not found) and if I didn't have the reference
and used the original, I got a undefined type error.
 
S

Steven Revell

I hadn't done it for the activeworkbook. I had a different workbook
selected when i added the reference.

Thanks for your help Tom and KeepItCool

Steven Revell
Applications Development & Support
Covance Laboratories Europe, UK

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top