View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Extended System Info

Last minute addition on the If Then construct. Guess I didn't get it
finished.

I would guess that non-office files don't have the extended properties
offered by the compound document format.

You can also play with the scripting runtime: This isn't set up as a
worksheet function.

Public Function DocProps(s As String)
Dim fs As Object 'Scripting.FileSystemObject
Dim fl As Object 'Scripting.File
Dim s1 As String
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(s) Then
Set fl = fs.GetFile(s)
s1 = fl.Name & vbNewLine & vbNewLine
s1 = "Created Date: " & Format(fl.DateCreated, "mm/dd/yyyy hh:mm:ss") _
& vbNewLine & "Last Accessed Date: " & _
Format(fl.DateLastAccessed, "mm/dd/yyyy hh:mm:ss") & _
vbNewLine & "Last Modified Date: " & _
Format(fl.DateLastModified, "mm/dd/yyyy hh:mm:ss")
Else
s1 = s & vbNewLine & "Doesn't exist"
End If
MsgBox s1

End Function


' modify this to test

Sub Testit()
Dim s As String
s = "E:\data\KZ081-Default Survey1.xls"
DocProps s
End Sub

--
Regards,
Tom Ogilvy


"Dallman Ross" <dman@localhost. wrote in message
...
In , Tom Ogilvy
spake thusly:

Since it is for a CSV file, don't you just want the file Data and
time you would see in Windows Explorer?


Yes, sir!

Function DocProp(s as String)
'Application.Volatile
if Dir(s) < "" then
DocProp = FileDateTime(s)
else
DocProp = "File Doesn't exist"
End Function

go to the vbe, Alt+F11, do Insert module, put in the above


usage
=DocProp("E:\My Documents\Records\Finance\Securities\Statements\20 06\SB
2006
Unrealized Gains, Trading.csv")


Cool beans! Works like a champ -- after I added the apparently
missing "End If" statement just before the end of the function.
Thank you so much!

Uncomment Application.Volatile if you think the CSV file will be changing
frequently.


Okay. It changes multiple times a week, typically.

Dankeschoen! Thanks very much also to Bob Phillips. I'm
intrigued with the bit of knowledge wrapped up in that
approach, also, and still would like to find out why
I'm having a file-perms problem trying to use it.

Dallman