Consulting

Results 1 to 14 of 14

Thread: Delete Table Styles

  1. #1
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location

    Delete Table Styles

    I can delete the gallery from the ribbon, but I'd like to get rid of the million (+/- 1) versions of the colorful styles that just clutter my style lists

    Tables Styles.jpg


    Didn't see any way to delete from the UI so tried a macro which didn't work just as well

    Option Explicit
    
    
    Sub Macro1()
        Dim i As Long
        
        For i = ActiveDocument.Styles.Count To 1 Step -1
            With ActiveDocument.Styles(i)
                
                If .Type = wdStyleTypeTable Then
                    
                    On Error GoTo ErrHandle1
                    Debug.Print i, .BuiltIn, .NameLocal
                    
                    On Error GoTo ErrHandle2
                    .Delete
                End If
            End With
            
            On Error GoTo 0
        Next
        
        Exit Sub
        
    ErrHandle1:
        Debug.Print "No NameLocal for " & ActiveDocument.Styles(i).NameLocal
        Resume Next
        
    ErrHandle2:
        Debug.Print "Could not delete " & ActiveDocument.Styles(i).NameLocal
        Resume Next
        
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    Try #2 -- I tried deleting the Table Styles using the Organizer, and the lying piece of software says it did, but they were still there
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Off with its head!!!!
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    Not even close to what I said when I thought that it had (finally) worked, but nothing had changed

    And some more for good measure
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Is there a way to make your preferred style the default goto option?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    I have an Autotext entry that inserts my 'Standard Table', which has

    1. 'Table Top" style applied to first row
    2. "Table Row" style applied to middle rows
    3. "Table Bottom" style applied to last row

    4. Table and Cell properties set (Vert alignment, padding, etc.)
    5. Repeat First Line set
    6. Don't Autosize cells
    7. Other settings

    Capture.JPG


    Once it's inserted, I can split columns, add/delete rows, etc. or redefine the 3 'Table' styles


    It's the screen clutter I was hoping to get rid of since I cannot see myself EVER using one of the pre-made table styles

    Capture2.JPG
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  7. #7
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    Just a note, Paul, that instead of AutoText, you can save as a "Quick Table" in the Windows versions of Word. Quick Tables
    AutoComplete works fine with the other Building Blocks Galleries once you get past Word 2010.

    Doesn't help with clearing the clutter, I'm afraid.

    Like you, I use the legacy drop-down for styles in my QAT. However, I generally know the name of the style I want and start typing it rather than use the menu. If you have a particular Table Style you do want to use from that menu, consider adding an alias for it's name so you can call it easily.

    As another workaround, the table styles do not appear in the Styles Pane. (I have it set to display all styles, alphabetically. It does not include the Table Styles.)

    Shauna Kelly, long ago in computer times, noted a lot of difficulty manipulating Table Styles with vba. http://www.shaunakelly.com/word/tablestyles/index.html

    BTW: I really appreciate your instructions in your signature block.
    Last edited by Chas Kenyon; 02-28-2022 at 10:35 AM.

  8. #8
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    1. Quick Table works nicely, or at least a little better that AutoText

    2; I think I'll remove the Styles dropdown from the QAT and go with the Styles Pane called up with a macro on the QAT

    Sub Macro2()
        CommandBars("Styles").Visible = True
    End Sub
    3. The link was interesting, but her macro didn't really do what I was expecting since the styles still showed

    Option Explicit
    
    
    'https://shaunakelly.com/word/styles/how-to-hide-table-styles-in-word.html
    Sub Macro1()
        Dim i As Long
        
        For i = ActiveDocument.Styles.Count To 1 Step -1
            With ActiveDocument.Styles(i)
                On Error Resume Next
                If .Type = wdStyleTypeTable Then
                    .Visibility = True ' Yes, True
                    .UnhideWhenUsed = False
                End If
                On Error GoTo 0
            End With
        Next i
        
        MsgBox "Done"
    End Sub
    4. I used Options to hide the Table Style Options and Table Style groups on the Table Design tab since the Table Style Options group only seems to be effective with the built in table sty;es

    Attachment 29455
    Attached Images Attached Images
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  9. #9
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    The Table Design Gallery will work with your own custom styles as well. It just becomes a question of finding them!
    If you save them to the template, they show up under Custom with your name as a pop-up. That requires showing the full gallery but Custom ones are in the first row.

    Like other table styles, they do show up in both the legacy drop down and the Apply Styles (Shift+Ctrl+S) dialog. When I create and save one, I start the name with an underscore so it shows up at the top of the list.

    I no longer bother putting the Styles Pane on the QAT since I use the keyboard shortcut of Ctrl+Shift+Alt+S (quite a stretch and takes both hands for me). I do like the Quick Styles Gallery there, though. Here is a link to my Styles QAT Add-In. It does include the Styles Pane, the legacy dropdown, the Quick Styles Gallery, and the Organizer.

  10. #10
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    Nice addins.

    I ended up just putting the Styles Pane on the QAT since I think that'll work for me for now, or at least until I change my mind.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  11. #11
    VBAX Regular
    Joined
    Jul 2012
    Posts
    29
    Location
    Hi Paul

    You could try this macro approach - run it on Normal.dotm and save the template. It will show "No Style". You can create your own Table Styles.

    Sub jec_HideAllTableStylesInDoc()Dim s As Style
    For Each s In ActiveDocument.Styles
    If s.Type = wdStyleTypeTable Then
    s.Visibility = True
    s.UnhideWhenUsed = True
    End If
    Next s
    End Sub

  12. #12
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    Quote Originally Posted by jec1 View Post
    Hi Paul

    You could try this macro approach - run it on Normal.dotm and save the template. It will show "No Style". You can create your own Table Styles.
    Thanks, I'd seen something similar,

    After a LOT of experimenting and trial and error, I finally ended up using a Quick Table since that preserves the styles for the Top, Middle, and Bottom rows.

    The out of the box standard Tables Format options were mostly borders and fills, which didn't help what I wanted to do

    I removed the 2 groups from the Table Format tab
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  13. #13
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    Quote Originally Posted by jec1 View Post
    Hi Paul

    You could try this macro approach - run it on Normal.dotm and save the template. It will show "No Style". You can create your own Table Styles.

    Sub jec_HideAllTableStylesInDoc()Dim s As Style
    For Each s In ActiveDocument.Styles
    If s.Type = wdStyleTypeTable Then
    s.Visibility = True
    s.UnhideWhenUsed = True
    End If
    Next s
    End Sub
    I like the macro, it is counterintuitive since turning on the visible property makes it hidden. It is effective for the Table Styles Gallery. The styles do still show up in the drop-down menu in the QAT.

    00 deleteme 9.jpg

  14. #14
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,727
    Location
    I like the macro, it is counterintuitive since turning on the visible property makes it hidden. It is effective for the Table Styles Gallery. The styles do still show up in the drop-down menu in the QAT.
    I removed the Styles Dropdown on the QAT because of that, and just went with the Style Pane on the QAT
    Last edited by Paul_Hossler; 03-02-2022 at 08:00 PM.
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •