Source

Read presentation

// open existing presentation
using var pres = SCPresentation.Open("some.pptx");

var shapeCollection = pres.Slides[0].Shapes;

// get number of shapes on slide
var slidesCount = shapeCollection.Count;

// get text
var autoShape = shapeCollection.GetByName<IAutoShape>("TextBox 1");
var text = autoShape.TextFrame!.Text;

Create presentation

// create a new presentation
var pres = SCPresentation.Create();

var shapeCollection = pres.Slides[0].Shapes;

// add new shape
var addedShape = shapeCollection.AddAutoShape(SCAutoShapeType.TextBox, x: 50, y: 60, width: 100, height: 70);

addedShape.TextFrame!.Text = "Hello World!";

pres.SaveAs("my_pres.pptx");


Tags: library   clr   msoffice  

Last modified 01 January 2023