Quote:
Originally Posted by gmaxey
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
|
Hi Greg!
I ran your code, but it didn't have the desired effect. I'm sure there's no problem with your code, but rather with where those styles are saved.
I assumed they were saved in the Active Document, but after debugging your Macro, all the values checked by the code match up correctly with the ones saved on the template. The thing is, I can see the undesired styles in the Style window, even if the code somehow ignores them.
I know this has turned into a loaded question, but is there a way to check (or "ask" the program) where a certain style is saved by giving it its name or something similar? Maybe that way I'd be able to modify the Macro you provided to work as intended.
In the (hopefully) attached screenshot you can see all the "garbage" styles I mean, which don't get picked up by the Macro code.
(Sadly, I can't send a sample document for legal reasons, not even after using a text scrambler, like I saw suggested on some other posts, so I understand if this question is impossible to solve as is)
Thank you for your time!
deleteMe.png