Reputation: 1346
Sorry my English :)
I need to set the background color second slide from fifth slide
static void Main(string[] args)
{
var presentationPath = @"d:\myPresentation.pptx";
var app = new PowerPoint.Application();
var presentation = app.Presentations.Open(presentationPath, WithWindow: MsoTriState.msoFalse);
var slide2 = presentation.Slides[2];
var slide5 = presentation.Slides[5];
slide2.FollowMasterBackground = MsoTriState.msoFalse;
var backgroundStyle = slide5.BackgroundStyle;
try
{
slide2.BackgroundStyle = backgroundStyle;
}
catch (Exception exception)
{
Console.WriteLine($@"Slide5.BackgroundStyle: {backgroundStyle.ToString()}");
Console.WriteLine(exception.Message);
Console.ReadKey();
}
finally
{
presentation.Close();
}
}
but code throw exception (second line):
Slide5.BackgroundStyle: msoBackgroundStyleNotAPreset
Slide (unknown member) : Integer out of range. 0 is not in the valid range of 1 to 12.
Upvotes: 2
Views: 916
Reputation: 1346
I solved problem
static void Main(string[] args)
{
var presentationPath = @"d:\myPresentation.pptx";
var app = new PowerPoint.Application();
var presentation = app.Presentations.Open(presentationPath, WithWindow: MsoTriState.msoFalse);
var slide2 = presentation.Slides[2];
var slide5 = presentation.Slides[5];
slide2.FollowMasterBackground = MsoTriState.msoFalse;
slide2.Background.Fill.ForeColor.RGB = slide5.Background.Fill.ForeColor.RGB;
}
Upvotes: 3