[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-04-29
11
Medium Priority
?
1,786 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
[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
  • 3
  • 3
  • 2
  • +1
11 Comments
 

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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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 1000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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 this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 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