Free Support Forum -

Attempting to alter an existing style

I am trying to update the "Normal" style in a new document. However an exception is thrown "Cannot add a style because a style with the same name already exists". What am I doing wrong?

Document doc = new Document();

StyleCollection styles = doc.getStyles();
Style style = styles.get("Normal");
if(style == null)
style = styles.add(StyleType.PARAGRAPH,"Normal");



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words for Java (4.0.0). Which version do you use?

You can download the latest version of Aspose.Words for Java from here:

Best regards,

Thanks, Mysteriously after turning on my computer this morning the problem has gone away! Oh well it works now.