Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 03-14-2023, 07:26 AM
gmaxey gmaxey is offline Delete every style in the document that isn't saved in the template Windows 10 Delete every style in the document that isn't saved in the template Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Perhaps:

Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oStyle As Style, oStyleValidate As Style
Dim oDocValidate As Document
Dim oTmp As Template
  Set oTmp = ActiveDocument.AttachedTemplate
  Set oDocValidate = oTmp.OpenAsDocument
  Set oStyle = ActiveDocument.Styles("Style1")
  For Each oStyle In ActiveDocument.Styles
    On Error Resume Next
    Set oStyleValidate = oDocValidate.Styles(oStyle.NameLocal)
    If Err.Number <> 0 Then
      oStyle.Delete
      Err.Clear
    End If
  Next oStyle
  oDocValidate.Close wdDoNotSaveChanges
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Tags
style, vba, word 16



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete every style in the document that isn't saved in the template USB disconnected while document was live; saved document now corrupt. How do I retrieve document? MaxB Word 2 07-01-2019 04:42 PM
My style keeps changing, can't get saved style to apply Meenie50 Word 7 07-20-2017 03:47 PM
Keyboard shortcut or QAT button for a saved paragraph style? VeazyT Outlook 0 05-15-2017 01:38 PM
How to make a fillable word template but not see what is not req'd to be filled in saved as document sjohnstone@edgeautomation Word 1 05-02-2017 10:05 AM
Delete every style in the document that isn't saved in the template Saved style set changing ljd108 Word 1 10-21-2014 11:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft