PDA

View Full Version : Sleeper: File Size warning



lior03
07-25-2005, 05:22 AM
hello
i have a huge workbook - 6,411,550 bytes.
i want excel to issue a warning when it reaches 7,500,000 bytes in size.


Sub sizere()
Dim x As String
x = ActiveWorkbook.Name
If filesize(x) >= 7500000 Then
MsgBox " this workbook is too big"
Else
MsgBox " watch it !!!!"
End If
End Sub
thanks

gsouza
07-25-2005, 05:42 AM
I don't think you can do that

Justinlabenne
07-25-2005, 06:21 AM
Using FileLen:


Option Explicit

Sub TooBigForYa()
Dim lSize As Long
Const lMax As Long = 7500000
lSize = FileLen(ThisWorkbook.FullName)
If lSize >= lMax Then
MsgBox "Too gosh darn big!....", 16
Else
MsgBox "File size is currently " & lSize
End If
End Sub

gsouza
07-25-2005, 06:23 AM
guess i was wrong again, never say never

Bob Phillips
07-25-2005, 07:48 AM
Using FileLen:

Be aware that this works on the saved file, not the file in memory. So as your workbook is growing, it won't be of much use to you. You will have to keep saving it, and then test the value.

sheeeng
07-25-2005, 07:53 AM
Nothing is impossible. :devil: