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,
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;
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 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...