Consulting

Results 1 to 10 of 10

Thread: Solved: bloating of file

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Solved: bloating of file

    I have written some code to automate some calculations at work.

    It all works fine but at the end of the calculation the file size is 7.5megs. I use ActiveWorkbook.Save at the end (of 31 pages of code) to save the file.

    However, when I re-open the file and press save again ( I do nothing else just open it and press save) the file size shrinks to 6.6 megs.

    Has anyone come across this before or do you know why it is happening.

    Like I said I dont do anything just open it and press save and it shrinks.

    I use Activeworkbook.SaveAs and ActiveWorkbook.Save but it still wont save as the smaller size.

    Help anyone?!?!?!?

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,734
    Location
    Try Tools, Options, Save tab, and disable "Auto Recover" and see if that helps

    Paul

  3. #3
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location
    that didnt work

    its really boggling my mind

  4. #4
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    Which version of Excel?
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location
    I believe it is 2000.

    I am not at work today but I think this is correct

  6. #6
    Site Admin VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,005
    Location
    Take a look at this link for de-bloating a file http://www.vbaexpress.com/forum/arch...php/t-496.html
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  7. #7
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location
    Thanks for the suggestion

    However I feel its not really practical to recreate the workbook regularly.

    I cant help but feel there is a more practical and sensible answer out there. There must be a reason Excel is doing this and thus there must be a way to capture and avoid or solve it.

    Someone out there must have the answer

    Help me Obi Wan Kanobi youre my only hope

  8. #8
    VBAX Mentor tstav's Avatar
    Joined
    Feb 2008
    Location
    Athens
    Posts
    350
    Location
    Hi Philfer,
    if recreating the file is a lot of work (and I agree that it sometimes is and gets to be unpractical, as you say) maybe you'd like to check out DRJ's KB entry http://www.vbaexpress.com/kb/getarti...kb_id=83#instr .
    All you'll have to do is run a macro.
    Could make an unbelievable difference to your file's size.
    If you are using Excel 2007, change the IV65536 address that Jake is using
    [vba].Range(Cells(1, LastCol + 1).Address & ":IV65536").Delete [/vba]
    to
    [vba]
    .Range(.Cells(1, LastCol + 1), .Cells(.Rows.Count, .Columns.Count)).Delete
    [/vba]

    Edit: It goes without saying that you always keep a backup file.
    He didn't know it was impossible, so he did it. (Jean Cocteau)

  9. #9
    VBAX Contributor
    Joined
    Jul 2004
    Location
    Gurgaon, India
    Posts
    148
    Location
    Check the autofilter mode is on. If it's on, make it off before closing the file.

  10. #10
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    You might try adding a loop at the end of your code before the save to explcitly reset the usedrange of each sheet - something like:
    [VBA]Dim rng as range, wks as worksheet
    For each wks in activeworkbook.worksheets
    set rng = wks.usedrange
    next wks
    set rng = nothing
    activeworkbook.save[/VBA]
    just to see if that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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