How to Open/View/Edit a PowerPoint presentation in a .NET WinForm application

Since .NET doesn't provide an OLE Container, what is the easiest way to insert the PowerPoint application inside a .NET WinForm? I need to access the content of the presentation, not just host it for viewing.
Who is Participating?
Sorry .. i mis-read the question. the way around this is to add the IE control in your form. one thing you also need to have installed is the Powerpoint addon for IE (which lets you view the presentations in IE). Once that's done then you'll have to call the Navigate(...) method of the IE control.

- Malhar
mrideyAuthor Commented:
Sorry no,

The first article relates to accessing a Word/Excel/Powerpoint object using Automation and modifying its properties. It doesn't show how to display the document inside a Winform window. Basically in the code given, the Word document remains hidden.

The second article shows how to create Add-ins for Word/Excel/Powerpoint to insert inside these applications. I need the opposite, ie, how to insert Word/Excel/Powerpoint inside a WinForm Application.

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Here is a workaround the oleautomation displayed;en-us;304562&Product=vsnet
the easiest way is .. first open the power point. start recording a macro. then do all the things manually that you'd want to eventually have your code do. stop the macro record.
go to your .net project. create a powerpoint object. and then reinsert the auto generated code from macro. ofcourse you'll have to make few changes, but after execution, end result would be exactly as you expected
mrideyAuthor Commented:
Great, it looks like article 3045628 and the additional links it provides will do the trick.
It works fine if the document exists but if I want to open a 'New' presentation, currently I would have to first open an existing presentation, then access the Automation object, and create a new presentation. a bit messy.

I recall a workaround to tell IE from a URL to load directly an ActiveX. The URL had a special syntax with a progid or something like similar.

refer to

great article

        Dim app As PowerPoint.Application
        Dim pres As PowerPoint.Presentation
        app = New PowerPoint.Application
        app.WindowState = PowerPoint.PpWindowState.ppWindowMinimized

        Dim sTemplate As String = "C:\Program Files\Microsoft Office\Templates\Presentation Designs\Blends.pot"

        Dim oSlide As PowerPoint.Slide
        Dim bAssistantOn As Boolean

        pres = app.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue)  '.Open(sTemplate) ', , , Microsoft.Office.Core.MsoTriState.msoTrue)

        oSlide = pres.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutTitleOnly)
        With oSlide.Shapes.Item(1).TextFrame.TextRange
            .Text = "My Sample Presentation"
            .Font.Name = "Comic Sans MS"
            .Font.Size = 48
        End With

        app.ActiveWindow.Selection.SlideRange.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShape5pointStar, 60.0#, 48.0#, 132.0#, 132.0#).Select()
        With app.ActiveWindow.Selection.ShapeRange
            .Fill.Transparency = 0.0#
            .Fill.Visible = Microsoft.Office.Core.MsoTriState.msoTrue
            .Fill.ForeColor.RGB = RGB(255, 255, 255)
            .Fill.BackColor.SchemeColor = PowerPoint.PpColorSchemeIndex.ppBackground
        End With
        app.ActiveWindow.Selection.SlideRange.Shapes.AddTextEffect(Microsoft.Office.Core.MsoPresetTextEffect.msoTextEffect14, "Hello World ! This is sooo cool !", "Impact", 36.0#, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, 132.38, 219.38).Select()
        With app.ActiveWindow.Selection.ShapeRange
        End With

        pres = Nothing
        app = Nothing
mrideyAuthor Commented:
Sorry no,

This article relates to accessing a Powerpoint object using Automation and modifying its properties. It doesn't show how to display the document inside a Winform window. Basically in the code given, the document remains hidden.
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.

All Courses

From novice to tech pro — start learning today.