Home > Enterprise >  Is there any way I can have excel automatically convert to the default theme before saving?
Is there any way I can have excel automatically convert to the default theme before saving?

Time:02-16

Please see the attached image. I have essentially created a Dark Mode template for myself. All I did was change the cell formatting (changed background,border,text colors) and moved this template to the XLSTART folder, which ensures that every new worksheet I open is consistent with this formatting.

The question I have, is that is it possible for me to work with this theme, but save the sheet in the default format? As much as I love working on this template, I can almost guarantee that some external parties that I send spreadsheets to will not appreciate this.

Essentially what I'm looking for is:

  1. Work with the custom "Dark" cell style that I have created.
  2. Save with the "Normal" (default) cell style in excel (essentially a macro that does "CTRL-A", and then clicks "Normal" cell style everytime I save a document.

Does anyone know if this is possible? I'm sure I can write a script in Python that does this, but it's faster to just press CRTL-A and click "Normal" instead of launching my IDE and running the script.

Thanks in advance!

Dark Mode Excel

CodePudding user response:

Yes, I have heard of Cells.ClearFormats, but not sure how I would implement this so that I don't have to manually run that command everytime.

CodePudding user response:

Inside of "ThisWorkbook", you can put a BeforeSave event, e.g.:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Cells.ClearFormats
End Sub

You can spruce this up to affect multiple sheets, etc.

  • Related