Create a PowerPoint Presentation Using C# and Embedding the Images
Today I will show how to Create PowerPoint Presentation
Using C# (Interop).
Creating PowerPoint Presentations Using Office Automation,
this will be very useful for IT departments and Organizations for their Employees.
We need to add following references
Embedding the Images in Microsoft PowerPoint Presentations.
using
Microsoft.Office.Interop.PowerPoint;
using
Microsoft.Office.Interop.Graph;
using
Microsoft.Office.Core;
Microsoft.Office.Interop.PowerPoint.Application
pptApplication = new
Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Interop.PowerPoint.Slides
slides;
Microsoft.Office.Interop.PowerPoint._Slide
slide;
Microsoft.Office.Interop.PowerPoint.TextRange
objText;
Presentation pptPresentation
= pptApplication.Presentations.Add(MsoTriState.msoTrue);
Microsoft.Office.Interop.PowerPoint.CustomLayout
customLayout =
pptPresentation.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];
// Create new
Slide
slides =
pptPresentation.Slides;
slide = slides.AddSlide(1,
customLayout);
// Add title
objText =
slide.Shapes[1].TextFrame.TextRange;
objText.Text = "journey to dotnet authority";
objText.Font.Name = "Trebuchet MS";
objText.Font.Size = 32;
string
innerChartFilePath = "D:\Images\Profile.png";
slide.Shapes.AddPicture(innerChartFilePath,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoTrue, 10, shape.Top, width,height);
pptPresentation.SaveAs(@"D:\Image"+DateTime.Now.Ticks.ToString()+".pptx",
Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsDefault,
MsoTriState.msoTrue);
pptPresentation.Close();
pptApplication.Quit();