Hi Aurelian,
Thanks for your inquiry. The following highlighted code snippet causes the exception of this issue. Could you please share some detail about your query what exact you want to achieve in DeleteStyle method? We will then provide you more information about your query along with code.
public static void DeleteStyle(Style style)
{
Style replaceWith;
switch (style.Type)
{
case StyleType.Paragraph:
replaceWith = style.Styles[StyleIdentifier.Normal];
break;
case StyleType.Character:
replaceWith = style.Styles[StyleIdentifier.DefaultParagraphFont];
break;
case StyleType.Table:
replaceWith = style.Styles[StyleIdentifier.TableNormal];
break;
case StyleType.List:
replaceWith = style.Styles[StyleIdentifier.NoList];
break;
default:
throw new ArgumentOutOfRangeException();
}
var normalName = replaceWith.Name;
replaceWith.Name = style.Name; // changing the style name replaces the style with the same name
replaceWith.Name = normalName;
}