What is NoList Style?

G

Greg Maxey

I was working with a macro that Klaus Linke posted the other day to remove
unused styles. Klaus explains that Normal, DefaultParagraph, and Heading1-9
sytles are built in and can't be removed. I have Word2003 and in my
Normal.dot there are two other styles that can't be removed: NormalTable
and NoList.

I added a line to Klaus' code to handle the NormalTable (skip it), but when
I tried to add a constant for the NoList style I could't fine one. I use
wdStyleNormalTable for the normal table, I looked through all of the
wdStyle constants and couldn't find one for NoList. I didn't try each one
as none looked promising. I would like to add a line in the below code
similiar to the Case statements for NormalTable and the other builtin
styles. Can anyone suggest what I should use? Thanks.

Sub DeleteUnusedStyles()
Dim oDoc As Document
Dim myStyle As Style
Dim myString As String
Dim i As Integer
Set oDoc = ActiveDocument
For Each myStyle In oDoc.Styles
If myStyle.InUse Then
Select Case myStyle
Case oDoc.Styles(wdStyleDefaultParagraphFont)
Case oDoc.Styles(wdStyleNormal)
Case oDoc.Styles(wdStyleNormalTable)
Case oDoc.Styles(wdStyleHeading1) To oDoc.Styles(wdStyleHeading9)
Case Else
Selection.Collapse (wdCollapseStart)
With Selection.Find
.ClearFormatting
.Style = myStyle
.Forward = True
.Wrap = wdFindContinue
.Execute FindText:="", Format:=True
If .Found = False Then
StatusBar = myStyle.NameLocal
If MsgBox("Delete", vbYesNo, myStyle.NameLocal) = vbYes Then
myStyle.Delete
End If
Else
myString = myString + myStyle.NameLocal & vbCr
End If
End With
End Select
End If
Next myStyle
MsgBox "In addition to Builtin styles, the" _
& vbCr & "following style(s) can't be removed:" & vbCr & myString
End Sub
 
J

Jay Freedman

Hi Greg,

The No List style seems to be the list equivalent of the Default
Paragraph Font style: applying it removes any "listness" from the
selection.

It appears that there isn't any predefined wdStyle constant for it,
but by devious means I found the right value. Put this line at the top
of your declarations and then you can use the name wdStyleNoList just
like any other:

Const wdStyleNoList = -108
 
K

Klaus Linke

Hi Greg,

I added "NoList" a while ago. Below's the macro as I currently use it.
One thing I'd still like to add is to check for linked styles (such as "char" styles), because deleting them -- even if they are not used -- can mess up the formatting in paragraphs formatted in the style they link to.

Greetings,
Klaus


Sub DeleteUnusedStyles()
Dim myStyle As Style
For Each myStyle In ActiveDocument.Styles
If myStyle.InUse Then
Select Case myStyle
Case ActiveDocument.Styles(wdStyleDefaultParagraphFont)
Case ActiveDocument.Styles(wdStyleNormal)
Case ActiveDocument.Styles(wdStyleNormalTable)
Case ActiveDocument.Styles(-108) ' No list
Case ActiveDocument.Styles(wdStyleHeading1) To _
ActiveDocument.Styles(wdStyleHeading9)
Case Else
Selection.Collapse (wdCollapseStart)
With Selection.Find
.ClearFormatting
.Style = myStyle
.Forward = True
.Wrap = wdFindContinue
.Execute FindText:="", Format:=True
If .Found = False Then
StatusBar = myStyle.NameLocal
Select Case MsgBox("Delete?", vbYesNoCancel + vbQuestion, myStyle.NameLocal)
Case vbYes
myStyle.Delete
Case vbCancel
Exit Sub
End Select
Else
Select Case MsgBox("Keep?", vbYesNoCancel + vbInformation, myStyle.NameLocal)
Case vbNo
myStyle.Delete
Case vbCancel
Exit Sub
End Select
End If
End With
End Select
End If
Next myStyle
End Sub
 
G

Greg Maxey

Klaus,

Thanks. I read your post the other day briefly and unfortunately deleted
it. I Googled for the basic subject yesterday. The post I found was over a
year old and NoList/NormalTable styles where not included. I added a couple
of Case statements to build a final message box listing unused styles that
were not removed:

Sub DeleteUnusedStyles()

Const wdStyleNoList = -108 'No built in constant in Word
Dim oDoc As Document
Dim myStyle As Style
Dim myString As String
Dim bHardStyles As Boolean

Set oDoc = ActiveDocument
For Each myStyle In oDoc.Styles
If myStyle.InUse Then
Select Case myStyle
'The following built-in styles can not be removed.
Case oDoc.Styles(wdStyleDefaultParagraphFont)
Case oDoc.Styles(wdStyleNormal)
Case oDoc.Styles(wdStyleNormalTable)
Case oDoc.Styles(wdStyleNoList)
Case oDoc.Styles(wdStyleHeading1) To _
oDoc.Styles(wdStyleHeading9)
Case Else
Selection.Collapse (wdCollapseStart)
With Selection.Find
.ClearFormatting
.Style = myStyle
.Forward = True
.Wrap = wdFindContinue
.Execute FindText:="", Format:=True
If .Found = False Then
StatusBar = myStyle.NameLocal
Select Case MsgBox("Delete?", vbYesNoCancel + vbQuestion, _
myStyle.NameLocal)
Case vbYes
myStyle.Delete
Case vbNo
bHardStyles = True
myString = myString + myStyle.NameLocal & vbCr
Case vbCancel
Exit Sub
End Select
Else
Select Case MsgBox("Keep?", vbYesNoCancel + vbInformation, _
myStyle.NameLocal)
Case vbNo
myStyle.Delete
Case vbNo
bHardStyles = True
myString = myString + myStyle.NameLocal & vbCr
Case vbCancel
Exit Sub
End Select
End If
End With
End Select
End If
Next myStyle
MsgBox "Unused built in styles and the following" _
& vbCr & "style\styles were not removed:" & vbCr & myString
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top