Click here to Skip to main content
12,829,374 members (38,667 online)
Click here to Skip to main content
Add your own
alternative version


16 bookmarked
Posted 25 Oct 2007

Automating MS PowerPoint Presentations

, 25 Oct 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
This article will demonstrate how to automate and get content from an MS PowerPoint presentation.


I have been working on automating MS Office applications since some time. I have seen that it is very easy to find information on automation of MS Word but it is difficult to find information on automation of other Office apps like PowerPoint, Excel.

So I decided to write one by myself and share the information with others.

Using the Code

Automation of PowerPoint is same as that for Word. Create a new project, go ahead and right click on References in Solution Explorer, and select Add Reference… When the Add Reference window comes up, select the COM tab. This will list all the component names which are available on your machine. Since we are going to use MS PowerPoint, we will scroll down until we find: Microsoft Power Point Object Library.

The following code will help youu understand the rest of the automation:

public string presentationExtract(string path)
    int slideNumber = 0;
    string heading = null;
    PowerPoint.Application PPTApp = null;
    PowerPoint.Presentation PPTPre = null;
    bool errorFlag = false;
    StringBuilder sb = new StringBuilder("");
    string wordArt = null;


        PPTApp = new PowerPoint.Application();
        PPTPre = PPTApp.Presentations.Open(path, Microsoft.Office.Core.MsoTriState.msoTrue, 
                 Microsoft.Office.Core.MsoTriState.msoTriStateMixed, 0);

        foreach (PowerPoint.Slide objSlide in PPTPre.Slides)
            slideNumber = objSlide.SlideNumber;
            heading = "\r\n\r\n" + "                PRESENTATION SLIDE " + 
                      slideNumber + "                " + "\r\n\r\n";

            foreach (PowerPoint.Shape objShape in objSlide.Shapes)
                    wordArt = objShape.TextEffect.Text.ToString();
                    sb.Append("\r\n" + wordArt + "\r\n");
                catch (System.Exception wordartException)
                    string temp = wordartException.Message.ToString();

                    sb.Append("\r\n" + objShape.TextFrame.TextRange.Text + "\r\n");
                catch (System.Exception textException)
                    string temp = textException.Message.ToString();
    catch (System.Exception error)
        string temp = error.Message.ToString();
        errorFlag = true;

    if (!errorFlag)
       return (newContent);
        return ("");

Points of Interest

I want to mention one thing here: I have used Office XP COM object and this can be used with MS Office 2003 and 2007.

Good luck guys...


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Govardhana Reddy
Web Developer India
India India
This is Govardhana Reddy, i am here to explore this world of INTERNET. I feel this is one way through which i can explore this world of INTERNET.

I want to be one among the best in this profession (a Software Developer, not a Software Engineer its a bit Controversial.) if not the "BEST"

My definition of a Software Engineer : "A person who knows what to cut/copy and where to paste".

Apart from my technical stuff I love Long Drives, Computer Gaming, Sports, Bikes and much more to say.

Anyways long road ahead keep me accompanied...

You may also be interested in...

Comments and Discussions

QuestionUsing automation without knowing MS Office version Pin
Kristian Regec29-Oct-07 23:56
memberKristian Regec29-Oct-07 23:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170326.1 | Last Updated 25 Oct 2007
Article Copyright 2007 by Govardhana Reddy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid