' sheet module
Private Sub Worksheet_Activate()
' desired theme
ActiveWorkbook.ApplyTheme ("C:\Program Files\Microsoft Office 15\Root\Document Themes 15\Facet.thmx")
'("C:\Users\XXX\AppData\Roaming\Microsoft\Templates\Document Themes\Tema1.thmx") user custom theme
End Sub
Hi
Code:' sheet module Private Sub Worksheet_Activate() ' desired theme ActiveWorkbook.ApplyTheme ("C:\Program Files\Microsoft Office 15\Root\Document Themes 15\Facet.thmx") '("C:\Users\XXX\AppData\Roaming\Microsoft\Templates\Document Themes\Tema1.thmx") user custom theme End Sub
Hi
What Excel version are you using? Details of a solution may be version specific.
To use the code, follow the steps below:
- Open the workbook.
- Press alt+F11 to go to the VBE.
- At the left pane, right click a worksheet and choose “show code”.
- Paste the code at the right pane.
- Press alt+F11 to return.
Now, activating that worksheet will apply the theme to the workbook. Check the code for a valid theme path (a .thmx file).
Another event that could be used is the workbook open event.
o The page below shows how to set a default Excel theme. If it is applied, produces the desired result and stays there, you do not need the code.
o Try manually applying a theme at page layout>themes. Does this remove the unwanted background colour?
o A workbook with macros must have the XLSM extension.
o The code expects a file path. On my example, it uses the “Facet.thmx” theme located at C:\Program Files\Microsoft Office 15\Root\Document Themes 15. You can take advantage of THMX files provided by Microsoft or create your own, as explained on the page below. The VBA only refers to a pre-existent theme file.
o A theme applies to the entire workbook.
https://support.office.com/en-us/ar...or-Excel-c846f997-968e-4daa-b2d4-42bd2afef904
o I understood what you want.
o I need an answer to this question:
Try manually applying a theme at page layout>themes. Does this remove the unwanted background colour?
o You are going to save the workbook as XLSM, not THMX. The code will reference a THMX file on your hard drive, provided by Microsoft.