Get File Size

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi I am trying to show the file size in a form, I have got a form that
collects file names and creation date modified date but I also want to show
the file size of each file found. can any body help to get the info above I
am using API functions but I can't find anything about file size.
TIA
Frank
 
Hi Frank.

Dim FLen as long

Flen = FileLen(ActiveWorkbook.FullName)
 
Thanks but it wont just be workbooks listed the form list all files in a
directory and puts the info into an access dB so I need to get file size for
each file found.
Thanks anyway.
 
Frank,

Here is a simple function to get fileinfo

Function FileInfo(path As String, Optional info As String = "Created")
Dim FSO As Object
Dim oFile As Object
Dim i As Long

Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFile = FSO.GetFile(path)

Select Case LCase(info)
Case "accessed": FileInfo = oFile.DateLastAccessed
Case "modified": FileInfo = oFile.DateLastModified
Case "created": FileInfo = oFile.DateCreated
Case "path": FileInfo = oFile.path
Case "size": FileInfo = oFile.Size
End Select

End Function

call it like so

fileinfo("C:\myTest\volker1.xls","Size")

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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

Back
Top