How to display PPT from C#

Posted on 2009-05-06
Last Modified: 2012-05-06
Hello experts,

I am creating a website which requires me to display power point presentation. I think this is how it is supposed to be done. (See Code below)

But my prob is. When i run the project from the local machine i can view the PPT, also when i run it inside the server, i can view it. But when i host the contents, And click on the link which is supposed to open PPT. It throws a run time error.  

Please help me solve this prob.
String strTemplate;
        strTemplate = ConfigurationManager.AppSettings["PPT"];
        PowerPoint.Application objApp;
        PowerPoint.Presentations objPresSet;
        PowerPoint._Presentation objPres;
        PowerPoint.Slides objSlides;
        PowerPoint.SlideShowWindows objSSWs;
        PowerPoint.SlideShowSettings objSSS;
        objApp = new PowerPoint.Application();
        objApp.Visible = MsoTriState.msoTrue;
        objPresSet = objApp.Presentations;
        objPres = objPresSet.Open(strTemplate,
            MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
        objSlides = objPres.Slides;
        objSSS = objPres.SlideShowSettings;
        objSSWs = objApp.SlideShowWindows;
        while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);

Open in new window

Question by:Priyadarshni
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
LVL 39

Expert Comment

ID: 24312100
It would be nice to see your runtime error, but I wouldn't be suprised it if is because you haven't installed Powerpoint on the target server yet.
LVL 39

Expert Comment

ID: 24312110
Adding to that: I don't see anywhere in your application where you are actually presenting the powerpoint slides to the browser. Instead, all I see is that you are running the powerpoint application, which is somethign you should not need to do (unless you want to use powerpoint to manipulate some content of the ppt presentation prior to displaying it online). Instead, all you need is a link to the ppt file and you're all set (assuming mimetypes are set correctly).

Author Comment

ID: 24312642
Thanks from replying,

I am getting the usual runtime error i.e

To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

And i did install the whole Microsoft office in the server.

My mistake. Haven't changed the string name. so i am passing the path of PPT to this variable.


Hmm... I think i am doing some thing wrong. No need to run the powerpoint application??
What needs to be instead?? I am sorry if i am asking simple and silly questions.



SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.


Author Comment

ID: 24312656
Are you saying that i need to do something like this??


Expert Comment

ID: 24312754
Even i faced the similiar problem with Microsoft Word, you need to consider the following before starting your server side automation with Word,PowerPoint or Excel.

Alternatives are included for server side automation.
LVL 39

Accepted Solution

abel earned 500 total points
ID: 24313284
> Are you saying that i need to do something like this??

yes and no. I suggest yo do something like this:

because: urls cannot contain backslashes, cannot be absolute file urls and should be relative to the root of your website (which is why I included the ~ sign). Instead of redirect, you can also just use this:

<a href="~/ppt/Sample.ppt" runat="server">go to powerpoint</a>
which will work just the same, maybe even clearer to your end-users.

In short: if you can upload your PPT to some directory relative to your website, or if you can just include them in your website project, you can use simple links and navigation and Powerpoint itself is not needed anymore.

Regardless the technique you use, users without powerpoint or the powerpoint viewer cannot see your slides (some other office software packages like Open Office do support powerpoint partially though).

Author Comment

ID: 24314288
I tried this

<a href="~/ppt/Sample.ppt" runat="server">go to powerpoint</a>

It asked the user to download the PPT... Is that alright??
Is it the correct method??

Can i just display the PPT rather than asking the user to download? If this can be done, Then how?
LVL 39

Expert Comment

ID: 24314526
> Is that alright??

well, that's what I would expect it to do. That's what it does for me when I click on a link for Word, PPT, Excel etc, unless you have instructed your browser to open it inside the browser. This link tells you more on what's actually going on: As you may find out, it is not as simple as it sometimes looks...

In my personal case: I always hate it if something opens in the browser, so I am glad I can configure it myself (actually, it is the default of most browsers, I believe).

LVL 39

Expert Comment

ID: 24314556
Instead of you reading the whole thread, when a user has PPT installed on his system, here's a qutoe from one of the comments that may help you to instruct your users:

Whether PPT/PPS files open in a browser window or are saved to disk and opened in PowerPoint/Viewer is] a client setting, either in the file-types (accessed through explorer menus different in different o/s vers, or via (.8, .9 etc. latest ver):  

@="Microsoft PowerPoint Presentation"
dword = 00000000 to open in a browser window
 dword = 1 to open in PPT.

Author Comment

ID: 24361487
Thank you.

I have used the below code.

<a href="~/ppt/Sample.ppt" runat="server">go to powerpoint</a>

Sorry for the late reply. But i was waiting for approval.


Author Closing Comment

ID: 31578357
Thank you. It solved my problem.
LVL 39

Expert Comment

ID: 24361639
Glad it worked out in the end with the link-approach,

-- Abel --

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting the Scene PowerPoint is a creative tool in the right hands but it also includes a much underutilised programming dimension. In this beginner level article, we're going to show you some of some key elements of programming PowerPoint using th…
Introduction In all recent versions of PowerPoint it is possible to trigger animations. This means the animation takes place when a certain shape is clicked. This allows you to run animation “on demand” and outwith the normal sequence of mouse cl…
This video teaches viewers how to create handouts from their slides and helps them decide how many slides to include per handout.
The viewer will learn how to edit the master slide. They will also learn how to combine multiple themes into one master slide to use them in their presentation.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question