Results 1 to 6 of 6
  1. #1
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Getting when file was created! (Excel 2000 >)

    Hi all, I got this code from a user and need some assistance in changing the code to have it do what they need. They sent me:

    >>> I open a file with visual basic and would then like to read the date when the file was created.
    I looked for the following code:

    <pre>Sub ShowFileInfo(filespec)
    ' Range("A1").Select
    Dim fs, f, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(filespec)
    s = "Created: " & fs.DateCreated
    MsgBox s
    End Sub</pre>



    But can not get it to give the result. I don
    Regards,
    Rudi

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Getting when file was created! (Excel 2000 >)

    The line

    s = "Created: " & fs.DateCreated

    should be

    s = "Created: " & f.DateCreated

    Use in the form

    Sub Test()
    ShowFileInfo ActiveWorkbook.FullName
    End Sub

  3. #3
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Getting when file was created! (Excel 2000 >)

    Gratefully thanx Hans. That one got me cornered!
    Regards,
    Rudi

  4. #4
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Getting when file was created! (Excel 2000 >)

    Hans,

    The client has come back with this query...

    "I download data from our system to c drive or network. Each month I replace the file with a new one with same name. The date created stays fix as on the date the file was created, e.g 28 June. I would like this to change. IS there something like Modified as in CreateObject as well."

    Is there a way to pick up the Modified date and how?? I think Excel does have a modified date in properties too!

    Any suggestions!
    TIA
    Regards,
    Rudi

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Getting when file was created! (Excel 2000 >)

    Surprise, surprise! Instead of

    s = "Created: " & f.DateCreated

    you can use

    s = " Last Modified: " & f.DateLastModified

    See for example File Object (Scripting).

  6. #6
    Gold Lounger
    Join Date
    Feb 2004
    Location
    Cape Town, RSA
    Posts
    3,444
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Getting when file was created! (Excel 2000 >)

    <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>...Tx
    I just did not know how to word it!
    Cheers
    Regards,
    Rudi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •