"Todd" <jenki...@yahoo.com> wrote in message
news:ac1101c250d1$7543cdc0$a5e62ecf@tkmsftngxa07...
MsgBox FileLen(Activeworkbook.FullName)
might do it for you.
Todd wrote:
>
> Can anyone tell me how to determine the file size for the
> active workbook (last saved version)?
--
Dave Peterson
ec3...@msn.com
Hi Todd
There are a number of ways to get this here is but one method
Function FileSzA(ByVal strFullFileName As String)
Dim handle As Integer
'// ensure that the file exists
If Len(Dir(FullFileName)) = 0 Then GoTo NoGo
'// open in binary mode
handle = FreeFile
Open FullFileName For Binary As #handle
'// read the string and close the file
FileSzA = LOF(handle)
Close #handle
Exit Function
NoGo:
Err.Raise 53
End Function
Sub TesterIII()
'// Just a few tests
MsgBox FileSzA("c:\autoexec.bat") \ 1024 & "Kb"
MsgBox FileSzA(ActiveWorkbook.FullName ) \ 1024 & "Kb"
End Sub
HTH
Ivan
"Dave Peterson" <ec3...@msn.com> wrote in message
news:3D70C441...@msn.com...
This would be one line in a macro that you could run by hitting
Tools|Macros|Macros... (after it was created).
To learn more about creating macros, you might want to visit David McRitchie's
site:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
There's lots of notes that to help get started (hence the name!).
It kind of sounds like you want to use put this kind of thing in the worksheet
(as a formula):
It this is true, then you might be able to use this User Defined Function (after
you learn about macros from David McRitchie's site!):
Option Explicit
Function FileSize(Optional FileName As Variant) As Variant
Application.Volatile
If IsMissing(FileName) Then
FileName = Application.Caller.Parent.Parent.FullName
End If
If Dir(FileName) = "" Then
FileSize = CVErr(xlErrRef)
Else
FileSize = FileLen(FileName)
End If
End Function
Then you can do things like:
=filesize("C:\autoexec.bat")
or even
=filesize()
(if the current workbook has been saved.)
--
Dave Peterson
ec3...@msn.com
"Dave Peterson" <ec3...@msn.com> wrote in message
news:3D7179DB...@msn.com...