PDA

View Full Version : [SOLVED:] Delete Table Styles



Paul_Hossler
02-25-2022, 05:32 AM
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

29448


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_Hossler
02-26-2022, 04:33 AM
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:(

Aussiebear
02-26-2022, 05:47 AM
Off with its head!!!!

Paul_Hossler
02-26-2022, 08:54 AM
Not even close to what I said when I thought that it had (finally) worked, but nothing had changed :banghead::banghead::banghead:

And some more :banghead::banghead::banghead: for good measure

Aussiebear
02-26-2022, 01:25 PM
Is there a way to make your preferred style the default goto option?

Paul_Hossler
02-26-2022, 07:11 PM
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

29450


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

29451

Chas Kenyon
02-28-2022, 10:15 AM
Just a note, Paul, that instead of AutoText, you can save as a "Quick Table" in the Windows versions of Word. Quick Tables (http://www.addbalance.com/usersguide/tables.htm#QuickTables)
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.

Paul_Hossler
02-28-2022, 11:58 AM
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

29455

Chas Kenyon
02-28-2022, 04:24 PM
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 (http://addbalance.com/word/download.htm#StylesQATAddIn). It does include the Styles Pane, the legacy dropdown, the Quick Styles Gallery, and the Organizer.

Paul_Hossler
03-01-2022, 04:21 AM
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.

jec1
03-02-2022, 02:02 PM
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

Paul_Hossler
03-02-2022, 02:28 PM
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

Chas Kenyon
03-02-2022, 05:53 PM
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.

29464

Paul_Hossler
03-02-2022, 06:59 PM
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