Style Validation or Creation   Return to List:

' Creating a "DeleteStyle" allows you to eliminate paragraphs containing certain characters from the document using a Find/ReplaceAll command --- because Word styles an entire paragraph even if certain characters within the paragraph are styled in a Find/ReplaceALL operation.

' To insure that the particular style is not used elsewhere (for something other than performing deletions) -- we create a uniquely named "DeleteStyle" -- if not already present.

X = ActiveDocument.Styles.Count
For i = 1 To X
    If "DeleteStyle" = ActiveDocument.Styles(i) Then
        GoTo CONTINUE
    End If
Next
' ************** If we dropped to here -- we need to create the new style ********
ActiveDocument.Styles.Add Name:="DeleteStyle", Type:=wdStyleTypeParagraph
With ActiveDocument.Styles("DeleteStyle")
    .AutomaticallyUpdate = False
    .BaseStyle = "Normal"
    .NextParagraphStyle = "DeleteStyle"
End With
With ActiveDocument.Styles("DeleteStyle").Font
    .Bold = True
    .ColorIndex = wdRed
End With

CONTINUE:



Note to Webmaster