?
Solved

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

Posted on 2004-04-29
11
Medium Priority
?
1,771 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
DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

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