?
Solved

How to display PPT from C#

Posted on 2009-05-06
12
Medium Priority
?
2,766 Views
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;
               objSSS.Run();
 
       
        objSSWs = objApp.SlideShowWindows;
        while (objSSWs.Count >= 1) System.Threading.Thread.Sleep(100);
 
        objApp.Quit();

Open in new window

0
Comment
Question by:Priyadarshni
[X]
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
12 Comments
 
LVL 39

Expert Comment

by:abel
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.
0
 
LVL 39

Expert Comment

by:abel
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).
0
 

Author Comment

by:Priyadarshni
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.

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

Response.redirect("C:\PPT\Sample.pps")
0
 
LVL 9

Expert Comment

by:Deathrace
ID: 24312754
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
 
LVL 39

Accepted Solution

by:
abel earned 2000 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:

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
 

Author Comment

by:Priyadarshni
ID: 24314288
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
 
LVL 39

Expert Comment

by:abel
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: 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
 
LVL 39

Expert Comment

by:abel
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):  

[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
 

Author Comment

by:Priyadarshni
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.


0
 

Author Closing Comment

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

Expert Comment

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

-- Abel --
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Setting the Scene Animations in PowerPoint are a great tool to convey messages when used carefuly with the content of your slides. There are plenty of animation effects and options, including a Repeat feature for individual animation effects. …
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 text. This includes Font, Spacing, Resizing, Color, and other special text options.
Suggested Courses

762 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