Solved

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

Posted on 2004-04-29
11
1,711 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now