This macro uses the Workbooks.Add method, which bypasses templates in the startup directories. Because of this, it works correctly even if templates in the startup directories have had extra styles added to them.
NOTE: The Excel File Recovery Macro has an option to remove all formatting from a workbook. To find information about this macro, or to download this macro, go to the Office Resource Kit.
For more information about the <I>Microsoft Office XP Resource Kit</I>, visit the following Microsoft Web site:
'The purpose of this macro is to remove all styles in the active
'workbook and rebuild the default styles. "Normal" cannot be
'deleted. Therefore the macro does not attempt to delete it.
'It rebuilds the default styles by merging them from a new workbook.
Dim MyBook As Workbook
Dim tempBook As Workbook
Dim CurStyle As Style
'Set MyBook to the active workbook.
Set MyBook = ActiveWorkbook
'Delete all the styles in the workbook.
For Each CurStyle In ActiveWorkbook.Styles
If CurStyle.Name <> "Normal" Then CurStyle.Delete
'Open a new workbook.
Set tempBook = Workbooks.Add
'Disable alerts so you may merge changes to the Normal style
'from the new workbook.
Application.DisplayAlerts = False
'Merge styles from the new workbook into the existing workbook.
Application.DisplayAlerts = True
'Close the new workbook.
ID d'article : 247933 - Dernière mise à jour : 24 déc. 2014 - Révision : 1