• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2806
  • Last Modified:

How to display PPT from C#

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;
               objSSS.Run();
 
       
        objSSWs = objApp.SlideShowWindows;
        while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);
 
        objApp.Quit();

Open in new window

0
Priyadarshni
Asked:
Priyadarshni
  • 6
  • 5
1 Solution
 
abelCommented:
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.
0
 
abelCommented:
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).
0
 
PriyadarshniAuthor Commented:
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.

strTemplate

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.


Priya.



 




0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
PriyadarshniAuthor Commented:
Are you saying that i need to do something like this??

Response.redirect("C:\PPT\Sample.pps")
0
 
DeathraceCommented:
Hi,
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.

http://support.microsoft.com/kb/257757

Alternatives are included for server side automation.
0
 
abelCommented:
> Are you saying that i need to do something like this??

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

Response.redirect("~/ppt/Sample.ppt")
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).
0
 
PriyadarshniAuthor Commented:
I tried this

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

But...
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?
0
 
abelCommented:
> 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: http://www.pptfaq.com/FAQ00189.htm. 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).


0
 
abelCommented:
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):  

[HKEY_LOCAL_MACHINE\Software\CLASSES\PowerPoint.Show.10]
@="Microsoft PowerPoint Presentation"
 "EditFlags"=hex:00,00,00,00
 "BrowserFlags"=dword:00000000  
dword = 00000000 to open in a browser window
 dword = 1 to open in PPT.
0
 
PriyadarshniAuthor Commented:
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.


0
 
PriyadarshniAuthor Commented:
Thank you. It solved my problem.
0
 
abelCommented:
Glad it worked out in the end with the link-approach,

-- Abel --
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now