We've set up our templates to use a style called "DocID". In older docs, it was a character style, in the new ones: paragraph. We also have docs that do not have the style at all.
We want to shoot for consistency.
I'm trying to write a macro that will create the DocID paragraph style if none exists. If the style name is in the collection, I want to delete it and add the new paragraph style.
Unfortunately, my error handler doesn't seem to be working. I suspect I'm using the wrong one, or I have it in the wrong location.
If the style exists, I get run time error 5173. "Style name already exists or is reserved for a built-in style."
Here's the code I'm trying:
On Error GoTo ErrSTYLE_NAME
Set MyStyle = ActiveDocument.Styles.Add(Name:="DocID", _
.Size = 7
.SpaceBefore = 6
.Alignment = wdAlignParagraphLeft