Home » excel » vba – Excel 2016 office 365 catastrophic failure

vba – Excel 2016 office 365 catastrophic failure

Posted by: admin May 14, 2020 Leave a comment


Start to get Excel catastrophic failure error

enter image description here

On OK opening debug windows, with auto creating each time new sheets, which is empty and strange structure

enter image description here

enter image description here

If I want something to do appears

enter image description here

So how to delete those sheets? or fix that error?
No background process started, file stored in xlsm and xlsb format do the same things. workbook and worksheets is not protected.

enter image description here

How to&Answers:

It looks like the file has been corrupted. It is unlikelly the problem can be easily reproduced from scratch.
Never the less you can script a vba macro to delete Sheets based on their names or not delete the sheets you want to keep.

sheetnametodelete= "sheetname"
With Application.Workbooks(ThisWorkbook.Name())
        .Unprotect (yourpassword)  ' required if protection is set
            Dim wks As Worksheet
            Set wks = .Sheets(sheetnametodelete)
            If (Not wks Is Nothing) Then ' also check if wks belong to the defined blacklist
            End If
        .Protect (yourpassword) ' required if protection is set
End With

Try to open the file from another computer in case your local Excel config is corrupted.

I had a similar problem (a fake workbook duplicated) in the past and decided to script a build process for my Excel vba based application.

See following links to learn more about module management.



you can also look at this post
Import a cls files and create a sheet

It provides code and comments from other contributors.
This is obviously not direct answer to your problem but if you intend to work on a consistent vba project I recommand to save your vba code out of your Excel file once in a while and setup a build of your Excel app.