Sometimes, if we have to format various retrieved documents, we may realize that the phrase “better to redo than to fix” is real. Thus, rather than adjusting certain complex or compromised styles, we can delete them. A few lines of VBA can quickly fix this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Sub StergeStiluriCustom() Dim doc As Document Dim stil As style ' Enables the current document Set doc = ActiveDocument ' Cycle through all styles in the document For Each stil In doc.Styles ' Check if the style is custom If stil.BuiltIn = False Then stil.Delete ' Removes the custom style End If Next stil MsgBox "All custom styles have been removed!", vbInformation End Sub |