.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> File Operation >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

powerpoint automation and c#

Posted By:Sreeraj Nair Mungath       Posted Date: July 11, 2012    Points: 40    Category: File Operation    URL: http://www.dotnetspark.com  

How to create powepoint application
 

Namespaces needed

using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;


namespace WindowsFormsApplication8
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

 

================================================================

            PowerPoint._Application ppApp;// a powerpoint applin 
            PowerPoint.Presentation ppMP;///a powerpoint presentation

            ppApp = new PowerPoint.Application();////opening a powerpoint applin 
            Microsoft.Office.Core.MsoTriState ofalse = Microsoft.Office.Core.MsoTriState.msoFalse;
            Microsoft.Office.Core.MsoTriState otrue = Microsoft.Office.Core.MsoTriState.msoTrue;
            ppApp.Visible = otrue;
            ppApp.Activate();

================================================================

 

//saving it
            ppMP = ppApp.Presentations.Open(@"C:\Users\snair02\Desktop\SRJ DOCS\raj.pptx",ofalse,ofalse,otrue);

             PowerPoint.Slides oSlides = ppMP.Slides;
            foreach (PowerPoint.Slide oSlide in oSlides)
            {
                foreach (PowerPoint.Shape shape in oSlide.Shapes)
                {
                    shape.TextFrame.TextRange.Text = shape.TextFrame.TextRange.Text.Replace("*", "Hi I am Sreeraj");
                }
            }
        }
    }
}


     

Further Readings:

Responses
Author: Hannah         Company URL: http://www.dotnetspark.com
Posted Date: January 01, 2014

You can create powerpint application in c#/.net with Aspose.Slides for .NET Library. YOu can add many features in your application by using this API. You can check out this library below:

http://www.aspose.com/.net/powerpoint-component.aspx

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend