Consulting

Results 1 to 6 of 6

Thread: Sleeper: File Size warning

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    Sleeper: File Size warning

    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
    Last edited by mdmackillop; 08-20-2005 at 03:19 AM. Reason: Title changed for search purposes
    moshe

  2. #2
    VBAX Contributor
    Joined
    Dec 2004
    Posts
    122
    Location
    I don't think you can do that

  3. #3
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location
    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
    Justin Labenne

  4. #4
    VBAX Contributor
    Joined
    Dec 2004
    Posts
    122
    Location
    guess i was wrong again, never say never

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Justinlabenne
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Nothing is impossible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •