views:

55

answers:

1

Does anyone know how to change the color of a selected range of text within a powerpoint add-in using C#?

+1  A: 

Well, if you're using interop...


 var app = new ApplicationClass();
 app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
 var myPresentation = app.Presentations.Open("c:\\test.pptx",
 Microsoft.Office.Core.MsoTriState.msoFalse,
 Microsoft.Office.Core.MsoTriState.msoFalse,
 Microsoft.Office.Core.MsoTriState.msoTrue);

 var slide1 = myPresentation.Slides[1];
 var range = slide1.Shapes[1].TextFrame.TextRange;
 range.Font.Color.RGB = -654262273;

And don't forget to

System.Runtime.InteropServices.Marshal.ReleaseComObject(<your com objects here>)
Software.Developer