Obtain imported file modified date

M

mikeburg

Help. Can someone please help me come up with the VBA code to obtain an
imported files modified date &:

(1) Place it in cell A1?

&

(2) Put it in a variable called FileDate?

Thanks a million. mikeburg
 
T

tony h

if you create a function such as

Function fLastModified(ByVal strFileName As String) As Variant

Dim v As Variant
On Error GoTo AnError
v = FileDateTime(strFileName)

fLastModified = v
GoTo TheEnd
AnError:
fLastModified = Err.Description
TheEnd:
End Function


then you can refernce it either direct from the worksheet or in code
 
T

Toppers

Hi,
This gets Date Modified for a given file.

HTH

Sub DateStamp()
Dim FileData As Date
Path = "C:\Documents and Settings\User\My Documents\My Excel\"
MyStamp = FileDateTime(Path & "book1.xls")
Range("a1") = MyStamp
Filedate = MyStamp
End Sub
 

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