2
I have a Word 2010 DOCX file and I'd like to hide all the fancy table styles that do not fit our CI/CD. It does not seem to be possible with the means of the UI, so I need a macro.
I tried the following
Sub Macro1()
Dim s As Style
For Each s In ActiveDocument.Styles
If s.Type = wdStyleTypeTable Then
If s.NameLocal <> "Table Grid" Then
Debug.Print (s.NameLocal)
s.Visibility = False
s.UnhideWhenUsed = False
Call s.Delete
End If
End If
Next
End Sub
which should hide and delete all table styles except "Table Grid", but there are still too many styles available.


I've never seen or even know what this is about. Although I have a long history of programming. VBa is another thing. But from what I can see, logically, the line
If s.Type = wdStyleTypeTable Thenis the mark where ONLY IF IT'S TRUE will it even do what you ask of it, which means only when that is true will the rest of the code be read by Excel. Hide fancy styles? Have you tried changing the Theme? It seems like an eye sore rather than a problem, maybe? Not sure. – ejbytes – 2016-09-22T09:54:33.187@ejbytes: yes, I want to do it for table styles only, not for paragraph styles or other styles. It's not so much of a problem if those styles are available. The real problem begins when people start using them because of personal preferences. I'm trying to ensure CI/CD by making it at least harder to use a "fancy" style. – Thomas Weller – 2016-09-22T11:14:35.377