A PowerPoint presentation can only be viewed either in Microsoft PowerPoint or in Microsoft PowerPoint Viewer. So if you are going to upload a PowerPoint presentation in your web site, then at least one of these two products must be installed in the user’s machine to view this PowerPoint presentation.
To overcome this limitation, you can convert the PowerPoint presentation to the HTML format and finally you can embed the generated HTML file in your web pages. So with this approach you can achieve following:
· The presentation can be embedded inside your web pages
· User will not need to install Microsoft PowerPoint or Microsoft PowerPoint Viewer to view the presentation.
Solution:
If you remember, there is an option in the File Menu of Microsoft PowerPoint:
File->Save As Web Page
This option will save a PowerPoint presentation in HTML format. We can also do this programmatically using C# and Microsoft Office API.
Following DLLs of Microsoft Office API will be required to achieve this functionality:
Interop.Microsoft.Office.Core.dll
Interop.PowerPoint.dll
Interop.Microsoft.Office.Core.dll
Use following C# code snippet to achieve this functionality:
//PowerPoint presentation file with full path
string strSourceFile = @“C:\PPT_Presentation.ppt”;
//Give the name and path of the HTML file to be generated
string strDestinationFile = @“C:\HTML_Presentation.htm”;
//Create a PowerPoint Application Object
PowerPoint.Application ppApp = new PowerPoint.Application();
//Create a PowerPoint Presentation object
PowerPoint.Presentation prsPres = ppApp.Presentations.Open(strSourceFile, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
//Call the SaveAs method of Presentaion object and specify the format as HTML
prsPres.SaveAs(strDestinationFile, PowerPoint.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTrue);
//Close the Presentation object
prsPres.Close();
//Close the Application object
ppApp.Quit();
Now look on second parameter of the “SaveAs” method, basically it specifies the format in which the PowerPoint presentation will be converted. In the above code it is “PpSaveAsFileType.ppSaveAsHTML”, means the PowerPoint presentation will be converted to HTML format. PpSaveAsFileType is an enum type which has following values:
· ppSaveAsAddIn
· ppSaveAsBMP
· ppSaveAsDefault
· ppSaveAsEMF
· ppSaveAsGIF
· ppSaveAsHTML
· ppSaveAsHTMLDual
· ppSaveAsHTMLv3
· ppSaveAsJPG
· ppSaveAsMetaFile
· ppSaveAsPNG
· ppSaveAsPowerPoint3
· ppSaveAsPowerPoint4
· ppSaveAsPowerPoint4FarEast
· ppSaveAsPowerPoint7
· ppSaveAsPresentation
· ppSaveAsPresForReview
· ppSaveAsRTF
· ppSaveAsShow
· ppSaveAsTemplate
· ppSaveAsTIF
· ppSaveAsWebArchive
So you can convert the PowerPoint Presentation to some other formats also, you just need to modify the value of the second parameter in the “SaveAs” method.
With the help of Microsoft Office API, you can also automate many other PowerPoint functionalities like programmatically creating PowerPoint presentation, etc.