0

I try to remove all build-in tables in my word template file except the custom styles I made. I've seen this following code (made my Neman) already but it removes all tables including my build-in table templates. I tried to change the code but it does not work for me. Can somebody help me out? Lets say, my custom tables are named like "custom1" and "custom2". How do I do it? :/ I'm really frustrated ..

Sub HideTableStyleButMakeItVisibleWhenUsed()
'Hides all non-XX tables from the Gallery unless user manually finds and applies it.

Dim MyTableStyle As Style

    For Each MyTableStyle In ActiveDocument.Styles

        If MyTableStyle.Type = wdStyleTypeTable Then

            If Left(MyTableStyle.NameLocal, 3) = "XX_" Then 'Remain visible in Gallery
                With MyTableStyle
                    .Visibility = False ' True if the specified style is visible as a recommended style in the Styles gallery and in the Styles task pane. Read/write.
                    .UnhideWhenUsed = True
                End With
            Else 'Hide in Gallery
                With MyTableStyle
                    .Visibility = True
                    .UnhideWhenUsed = True
                End With
            End If

        End If

    Next MyTableStyle

End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.