+ Reply to Thread
Results 1 to 26 of 26

Excel shutting down during save

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Excel shutting down during save

    Okay, I've got a strange problem. The macro below WAS (yesterday) working well to save the active workbook to a specific location with a specific name. Now, Excel shuts down when it hits that bit of code. Any idea what would be causing it? BTW, it tries to save to the location; there's an unknown type of fill deposited there, with a name like "7A08C000". If I put an XLS extension on it it says the file format is not valid.

    If I change "ActiveWorkbook" to "TwoB" I get the same result. But, if I make a different workbook the active workbook, the macro works.

    Please Login or Register  to view this content.
    EDIT: I edited the post to attach a copy of the Lookups sheet.
    Attached Files Attached Files
    Last edited by jomili; 07-25-2011 at 12:15 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    Okay, I've done some more testing, and I can narrow down the problem even more.

    The problem seems to be triggered by the HO and MO variants; for some reason Excel doesn't seem happy about those two. Any ideas on another way to do it?

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    I still need help.

    I tried this morning just saving the active workbook with a new name.
    Please Login or Register  to view this content.
    Same reaction, Excel shuts down and offers to recover my work.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    Two thoughts spring to mind:
    1. Use HO.Value and MO.Value
    2. Don't call your sub Save as that is an Excel method
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    Romper,

    Thanks for the advice, but no go. I tried putting .value after MO and HO, and still got the same reaction. "Save" was just a temporary macro, not the full routine, so I changed the name to "SaveIt". As a separate routine, if I just run it over and over, sometimes it will work, sometimes it won't. As part of the larger routine, it fails every time, but catastrophically, by shutting down Excel. I've pasted the larger routine below; it's a lot to go through, but maybe it will give you a clue as to what's happening.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by jomili; 07-25-2011 at 08:54 AM.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    A couple of immediate questions/observations:
    1. Why are you using Run rather than calling the code directly?
    2. There's a lot of unnecessary selecting, activating and unqualified Range statements in there.
    3. What are the values of HO and MO?

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    1) Self-taught in VBA, so blame my teacher that I don't know the right code to use. What do you mean by "Call directly", rather than "Run"?

    2) You'd have to point out specifics for me to explain the "why"s of these.

    3)
    Please Login or Register  to view this content.
    TwoB is the workbook that contains the Lookups sheet I attached to my first post. HO and MO are in there.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    1. I mean:
    Please Login or Register  to view this content.
    rather than:
    Please Login or Register  to view this content.
    2. For example here:
    Please Login or Register  to view this content.
    you would be better off explicitly stating which sheet is being used. The odd thing is that sometimes you do it and others you don't - such as in this part:
    Please Login or Register  to view this content.
    where you have two fully qualified Range references, one unqualified one, then one qualified only with Activesheet.

    3. That doesn't tell me what the values are.

  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    Run or Call;
    I just did some research, and it appears you use Run when you're calling a macro from another workbook, Call when you're running a macro within a workbook. All of my macros are run from one workbook, and they all modify another workbook, and use other workbooks. So that's why I use Run.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    If the code is all in the same workbook, you don't use Run, regardless of which workbook is being modified. If you do use Run, you should specify the workbook that the code is in.

  11. #11
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    For 1), are you saying I could just put Killbutts, with nothing else, and "Killbutts()" would run?

    For 2, you're right. I had thought
    Please Login or Register  to view this content.
    would cover all of the code under it until my "End With", but my WITH is only talking about A1, not the other cells. Sloppy of me; I'll work on that.

    For 3, I don't remember what values were in the workbook I first posted, as they change depending on what month we're in a what region we're running. Representative values are June for H1, 030 for M1.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    1. Yes. You can also use
    Please Login or Register  to view this content.
    but it is unnecessary.

    Do you have any code in the BeforeSave event as a matter of interest?

  13. #13
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    No, nothing before save. Would it help if I posted the workbook that all of my code is in? A lot of it wouldn't run, as it depends on other workbooks, but you're welcome to inspect the code if you'd like.

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    Feel free - though if it's a lot of code I can't guarantee when I can look through it.

  15. #15
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    It's getting worse. When my active workbook (TwoB) is created, it's automatically saved to my desktop. So, I added a routine right before my attempted save to the new drive, to save the active workbook, no name change or anything. Excel crashed again, no error message other than Excel is attempting to save my work. The code I used to save my workbook is simply
    Please Login or Register  to view this content.
    . I use it successfully in previous macros, but at the point in question it causes Excel to crash.

    I've attached my workbook containing all of my code in the hope that someone can pinpoint the problem. As it stands now, ActiveWorkbook.Save works in the "Lookups" macro, but fails in the "Finish" macro. Any help is greatly appreciated.
    Attached Files Attached Files

  16. #16
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    Okay, I've narrowed it down more. ActiveWorkbook.Save works BEFORE "Killbutts", but ActiveWorkbook.Save immediately after "Killbutts" causes Excel to fail. So, I'm thinking "Killbutts" might be the problem, I just don't know why. If I remove Killbutts, it runs flawlessly.

    Here's "Killbutts"; it's purpose is to delete some autoshape buttons on the active sheet. It seems to work well, but something's going wonky with it.
    Please Login or Register  to view this content.
    BTW, Killbutts grew from this post: http://www.excelforum.com/excel-prog...-coloring.html

  17. #17
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    My initial impression is that your workbook is corrupt as it keeps leaving shadow copies of itself open in the VBE (though it doesn't crash when I save it). My earlier points still apply though, and you ought to use Thisworkbook to refer to the workbook running the code, rather than hardcoding its name into the code.

  18. #18
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    Comment out the shape delete, then test it again.

  19. #19
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    Running it like this, everything works fine (except my buttons aren't deleted):
    Please Login or Register  to view this content.

  20. #20
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    How about if you use:
    Please Login or Register  to view this content.

  21. #21
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    That works, no Excel failure. It deletes my two buttons, but it doesn't delete the two red rectangular autoshapes I had behind my two buttons.

  22. #22
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    Try replacing the loop with:
    Please Login or Register  to view this content.
    and see if that does it. It's generally not a good idea to just delete all shapes on a sheet, especially if you have autofilters, data validation and the like on it.

  23. #23
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    Romper, thanks for the advice on deleting shapes. I'm not at all familiar with shapes, so this stuff is all new to me.

    I changed Killbutts as you suggested, and it's doing the trick now with no hiccups. Thank you very much for helping me locate and fix the problem. I'll see if I can implement all your suggestions for tightening up my code.

    Thanks,
    John

    Please Login or Register  to view this content.

  24. #24
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    Glad to help. All good fun, isn't it?

  25. #25
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,974

    Re: Excel shutting down during save

    Sure. Except for all my hair falling out, a nervous giggle whenever I speak, and the twitching of the whole left side of my face, I'm having the time of my life!

  26. #26
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,324

    Re: Excel shutting down during save

    Only the left side? Give it time.

    Oh, and please don't forget to mark Solved. Ta.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1