Solved

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

Posted on 2004-04-29
11
1,727 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:mridey
  • 3
  • 3
  • 2
  • +1
11 Comments
 
LVL 21

Expert Comment

by:tovvenki
ID: 10956250
0
 

Author Comment

by:mridey
ID: 10956398
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.

Thanks
Marc.
0
 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 10958614
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 25

Expert Comment

by:RonaldBiemans
ID: 10958638
Here is a workaround the oleautomation displayed
http://support.microsoft.com/default.aspx?scid=kb;en-us;304562&Product=vsnet
0
 
LVL 9

Expert Comment

by:malharone
ID: 10963279
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
0
 

Author Comment

by:mridey
ID: 10964381
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.

Thanks
0
 
LVL 9

Expert Comment

by:malharone
ID: 10964712
refer to http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q303/7/17.ASP&NoWebContent=1

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
            .Fill.PresetTextured(Microsoft.Office.Core.MsoPresetTexture.msoTextureGreenMarble)
        End With
        app.ActiveWindow.Selection.Unselect()
        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
            .IncrementLeft(95.62)
            .IncrementTop(-195.38)
        End With

        pres.SaveAs("c:\test.ppt")
        pres.Close()
        pres = Nothing
        app.Quit()
        app = Nothing
        GC.Collect()
0
 

Author Comment

by:mridey
ID: 10983874
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.
0
 
LVL 9

Accepted Solution

by:
malharone earned 250 total points
ID: 10984020
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
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

770 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