Set border color to theme color

I used the following code to set the border color to Accent1.

var border = doc.Styles[StyleIdentifier.Heading1].ParagraphFormat.Borders[BorderType.Bottom];
border.LineStyle = LineStyle.Solid;
border.Color = doc.Theme.Colors.Accent1;

When I change the Accent 1 theme color in Word, the border color does not change accordingly.

The Font class has a ThemeColor property that allows me to specify a theme color. However, there is on similar properties in the Border class. How do I properly set the border color to a ThemeColor?

@bingxie Theme.Colors.Accent1 gets or sets the color Accent 1. This property type System.Drawing.Color. So when you set border color like this:

border.Color = doc.Theme.Colors.Accent1;

Border color is simply set to the color stored in Theme.Colors.Accent1 property it dies not set reference to this color.
Unfortunately, currently there is no way to set border color as theme color. I have logged this feature request as WORDSNET-24325. We will keep you updated and let you know once it is implemented.

1 Like

Any update @alexey.noskov?

We are also seeing this problem in Shape FillColor and StrokeColor.

Right now, we have to patch XML in .docx files generated by Aspose.Words to overcome this issue.

@bingxie Unfortunately, the appropriate public API is not implemented yet. Currently the issue is in the queue for analysis. Once analysis is done we will be able to provide you more information.

Thanks @alexey.noskov Please do let us know when you have an update.

@bingxie We have completed analyzing the issue. Currently we plan to implement this in 22.12 (December 2022) version of Aspose.Words. We will keep you informed and let you know once the issue is resolved.

The issues you have found earlier (filed as WORDSNET-24325) have been fixed in this Aspose.Words for .NET 24.1 update also available on NuGet.