Powerpoint幻灯片背景颜色设置不正确

本文关键字:设置 不正确 颜色 背景 幻灯片 Powerpoint | 更新日期: 2023-09-27 18:13:06

我使用以下代码将幻灯片添加到演示文稿中,然后我想将其背景颜色设置为演示文稿中已存在的其中一张幻灯片的颜色:

presentation.Slides.AddSlide(presentation.Slides.Count + 1  presentation.Slides[presentation.Slides.Count].CustomLayout);
//set the last slide color to the color of the current slide
presentation.Slides[presentation.Slides.Count].Background.Fill.ForeColor.RGB = presentation.Slides[e].Background.Fill.ForeColor.RGB;
presentation.Save();

但是,颜色不会被设置为红色。右边的值是255,这是我想要的,但左边的值是11675(在我设置颜色的行之前和之后)。如何解决这个问题?

Powerpoint幻灯片背景颜色设置不正确

问题解决了:

 int slide_color = presentation.Slides[e].Background.Fill.ForeColor.RGB;
 presentation.Slides[presentation.Slides.Count].Design.SlideMaster.Background.Fill.ForeColor.RGB = slide_color;