+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26

Thread: Excel shutting down during save

  1. #16
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    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.
    Sub Killbutts()
    'Activate sheet to delete autoshapes.
    Dim GetShape As Shape
        For Each GetShape In ActiveSheet.Shapes
            GetShape.Delete
        Next
        With ActiveSheet
        'Return our rows to normal
                Rows("1:8").RowHeight = 15
        'Remove the Color and words from our range
                Range("C1:F7").ClearContents
                Range("C1:F7").Interior.ColorIndex = xlNone
        End With
    End Sub
    BTW, Killbutts grew from this post: http://www.excelforum.com/excel-prog...-coloring.html

  2. #17
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    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.

  3. #18
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Excel shutting down during save

    Comment out the shape delete, then test it again.

  4. #19
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    Re: Excel shutting down during save

    Running it like this, everything works fine (except my buttons aren't deleted):
    Sub Killbutts()
    'Activate sheet to delete autoshapes.
    'Dim GetShape As Shape
        'For Each GetShape In ActiveSheet.Shapes
            'GetShape.Delete
        'Next
        With ActiveSheet
        'Return our rows to normal
                Rows("1:8").RowHeight = 15
        'Remove the Color and words from our range
                Range("C1:F7").ClearContents
                Range("C1:F7").Interior.ColorIndex = xlNone
        End With
    End Sub

  5. #20
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Excel shutting down during save

    How about if you use:
    Sub Killbutts()
    'Activate sheet to delete autoshapes.
    Dim GetShape As Button
        For Each GetShape In ActiveSheet.Buttons
           GetShape.Delete
        Next GetShape
        With ActiveSheet
        'Return our rows to normal
                Rows("1:8").RowHeight = 15
        'Remove the Color and words from our range
                Range("C1:F7").ClearContents
                Range("C1:F7").Interior.ColorIndex = xlNone
        End With
    End Sub

  6. #21
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    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.

  7. #22
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Excel shutting down during save

    Try replacing the loop with:
    activesheet.drawingobjects.delete
    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.

  8. #23
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    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

    Sub Killbutts()
        With ActiveSheet
            .DrawingObjects.Delete
        'Return our rows to normal
                Rows("1:8").RowHeight = 15
        'Remove the Color and words from our range
                Range("C1:F7").ClearContents
                Range("C1:F7").Interior.ColorIndex = xlNone
        End With
    End Sub

  9. #24
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Excel shutting down during save

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

  10. #25
    Forum Guru
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Excel 2010
    Posts
    1,502

    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!

  11. #26
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    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.2.0