+ Reply to Thread
Results 1 to 13 of 13

How to clean up corrupt styles in excel 2013

  1. #1
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    How to clean up corrupt styles in excel 2013

    I am upgrading to excel 2013. I work with large workbooks 20mbs, 30 worksheets is about average. I get data from many sources, and many hands are in my files. I have the macro that deletes corrupt styles. However a few hundred corrupt styles will not delete using the macro or manually. The only way I have found to delete the corrupt styles is to zip the file and then delete the style portion. This deletes all formatting so then I have copy each sheets formatting in which can be tedious. In excel 2013 is there a better way to clean up the corrupt styles? I had read somewhere that Microsoft was working on this issue.

    Any insight would be greatly appreciated.

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: How to clean up corrupt styles in excel 2013

    it'd easier to help with an example

  3. #3
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How to clean up corrupt styles in excel 2013

    corrupt styles.xlsx

    here is an example. All of the custom styles are corrupt, but can't be deleted.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to clean up corrupt styles in excel 2013

    Any improvement if in styles.xml you delete only from cellstyles to /cellstyles? (the forum won't let me show the html tags)
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How to clean up corrupt styles in excel 2013

    shg,

    I'm not sure what you are suggesting. I tried saving the file as an XML workbook, but I couldn't reopen it then. I did notice that the file size went from 18mb to 633mb. Might have something to do with why it wouldn't open it.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to clean up corrupt styles in excel 2013

    1. Change the extension from xlsm or xlsb to zip

    2. Open the zip file, navigate to the xl folder, and copy styles.xml to a convenient location

    3. Open styles.xml with a text editor. Locate the open and close cellstyles tags, and delete them and everything between.

    4. Save the file, and copy back to the zip file

    5. Restore the original extension.

  7. #7
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How to clean up corrupt styles in excel 2013

    When I open the zip file I get a styles.bin not styles.xml. When I open the styles.bin with a text editor all I get is a lot of weird characters. I don't see an an xl folder or any folders for that matter.

    In the past I have done something similar, where I just delete the styles.bin. When I open the file it goes through repairs, then everything is fine except all my formatting is lost. If I only had to do this once in a while it wouldn't be a big deal. Unfortunately every time someone copies in a small amount of data I pick up all of this cr** again.

    Thanks for your advice!!

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to clean up corrupt styles in excel 2013

    You'd need to save the file as an xlsx file to see the text in the styles.xml. The xlsb file generates a styles.bin, which cannot be read.
    The downside of deleting the styles.xml file is that most of the formatting in the workbook goes to the default.

    BTW...I have a huge issue at work with cryptic cell styles. They're typically generated by automated report generators that create names that are highly unlikely to conflict with any human-created cell styles. I've had to clean workbooks with tens of thousands of custom cell styles. Many times those "ghost styles" remain.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to clean up corrupt styles in excel 2013

    Quote Originally Posted by shg View Post
    1. Change the extension from xlsm or xlsb to zip
    Sorry, that was a typo -- it should have said "xlsm or xlsx to zip"

    Ron, thank you.

  10. #10
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How to clean up corrupt styles in excel 2013

    Yes, that worked. Save a 20mb xlsb file as a 45mb xlsx file. Then rename to zip file. Open zip file, edit styles.xml (huge text file). Update zip file, rename to xlsx file.
    Open xlsx file then resave as xlsb file.

    Seems a bit tedious for something I may have to do several times a week on various files. I was hoping in a newer version of excel Microsoft would fix the issue and just make it a click of a button fix.

    Thanks for the help.

  11. #11
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to clean up corrupt styles in excel 2013

    Something else to check if you're ending up with an extraordinary number of cell styles....hidden Range Names

    Put this code on your PERSONAL.XLSB file:
    Please Login or Register  to view this content.
    Many times, when I get a workbook with cryptic cell styles it also has hidden cryptic range names. I've seen hundreds of them in some files. Not only are they annoying, but large numbers of named ranges can make a workbook sluggish.

  12. #12
    Forum Contributor
    Join Date
    08-17-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    106

    Re: How to clean up corrupt styles in excel 2013

    I use similar code on a regular basis. Excel carries over named ranges styles etc when a cell is copied and pasted from an outside workbook. I try to train my co-workers to use paste special values but that is a huge uphill battle.

    Thanks

  13. #13
    Registered User
    Join Date
    02-18-2022
    Location
    Geneva
    MS-Off Ver
    365
    Posts
    1

    Re: How to clean up corrupt styles in excel 2013

    Thanks for the hint. However, the format has to be "xlsm" for it to contain a "styles.xml" file that can be edited with a text editor. The second option of "xlsb" is not valid for this. Instead, it will contain a file "styles.bin". This supposedly can be edited a hex editor, but it is not clear to me how this works. With "styles.xlm" it is easy as you see the styles delimited with tags.
    My workaround was to first save the file as "...xml" from EXCEL before changing the extension to "zip".

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Deleting Corrupt styles
    By Steve in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2018, 01:30 AM
  2. Replies: 0
    Last Post: 01-28-2015, 01:25 PM
  3. [SOLVED] Excel 2013: How to Start Excel with Macros and Custom Styles, Format
    By snapfade in forum Excel General
    Replies: 23
    Last Post: 04-25-2014, 04:29 PM
  4. Do 2010 and/or 2013 corrupt 2003 files?
    By Oppressed1 in forum Excel General
    Replies: 1
    Last Post: 07-09-2013, 02:49 PM
  5. Replies: 1
    Last Post: 03-08-2013, 02:05 PM
  6. Unstable/Corrupt Excel File / How to clean it
    By mcpop72 in forum Excel General
    Replies: 0
    Last Post: 10-13-2008, 12:50 PM
  7. Removing Corrupt styles in an excel workbook
    By anonymouse in forum Excel General
    Replies: 1
    Last Post: 12-17-2005, 11:25 AM

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