C# .NET - How to run Power Point Viewer on a Windows Label Control

Asked By Bijaya Kumar Pathia on 13-Sep-08 08:18 AM

Hi All

      I want to run the Power Point Viewer on Windows Panel Control. I have used the Process class to start the proces PPTVIEW.exe. But it starts in its default window. I want to start the PPTVIEW on my windows panel control. Is there any way to achieve this.

Thanks

 Bijaya

See this to run Power Point Viewer - Sagar P replied to Bijaya Kumar Pathia on 13-Sep-08 08:27 AM

Click on Add Reference -> Switch to the COM Tab -> and choose the "Microsoft Powerpoint XX Object Library".

There you can use all the functionalitites of powerpoint;

Or

see this code may be this will solve your problem;

Public Class Form1

    Declare Function SetParent Lib "user32" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim ppviewer As String = "C:\Program Files\Microsoft Office\Office12\PPTVIEW.EXE"
        Dim MyPSI As New ProcessStartInfo(ppviewer)
        MyPSI.Arguments = "c:\mypowerpoint.ppt /s"
        Dim MyProcess As Process = Process.Start(MyPSI)
        MyProcess.WaitForInputIdle()
        SetParent(MyProcess.MainWindowHandle, Panel1.Handle)
    End Sub

End Class
 
http://www.vbforums.com/showthread.php?t=526224

Best Luck!!!!!!!!!!!!!!!!!!
Sujit.

How to run Power Point Viewer on a Windows Label Control: Solution - Perry replied to Bijaya Kumar Pathia on 14-Sep-08 03:24 AM

Hi,

You can use Web Browser Control. This will shows the PPT slides one at a time and if you want to scroll all ppt slieds then the only way I can see you doing this programatically would be to open the file, loop through the sheets, perform a shreenshot on each and output this to a series of image container controls dynamically - this wouldn't be elegant, is prone to errors and would cause a terrible flicker on screen.

I've just been through the PowerPoint object model, and .Net/COM toolbox items and can't see anything there at all. It is possible if you had VB6 still you could look at the ole control, but again I'd expect this would just show individual slides. Please use following code that I have used from VB that might helps you to proceed furthere.

Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop
Imports System.IO
Imports System.Runtime.InteropServices

Public Enum ExportImageType
  JPG
  BMP
  PNG
  GIF
End Enum

Public Class PowerPointExporter

  Public Shared Sub ExportPresentation(ByVal fileName As String, ByVal outputPath As String, ByVal imageType As ExportImageType, ByVal width As Integer, ByVal height As Integer)

    If Not File.Exists(fileName) Then
      Throw New FileNotFoundException(fileName)
    End If

    If Not Directory.Exists(outputPath) Then
      Throw New DirectoryNotFoundException(outputPath)
    End If

    Dim app As New PowerPoint.Application()
   ' app.Visible = MsoTriState.msoFalse

'for Office 2003
    Dim presentation As PowerPoint.Presentation = _
      app.Presentations.Open(fileName, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoTrue)

'for Office 2007
'       Dim presentation As PowerPoint.Presentation = _
          app.Presentations.Open2007(FileName:=fileName, ReadOnly:=MsoTriState.msoTrue, WithWindow:=MsoTriState.msoTrue)

    For Each slide As PowerPoint.Slide In presentation.Slides
      Dim name As String = IIf(slide.Name.Trim().Length = 0, slide.SlideIndex, slide.Name)
      Dim outputFileName As String = Path.Combine(outputPath, name) & "." & imageType.ToString()
      slide.Export(outputFileName, imageType.ToString(), width, height)
      Marshal.ReleaseComObject(slide)
    Next slide

    Marshal.ReleaseComObject(presentation)
    Marshal.ReleaseComObject(app)

  End Sub

End Class

Please refer http://www.vbforums.com/showthread.php?t=526224 where user face lots of troubles and also he tried to enhanced the application at the best level.
 
-Paresh

RE - Bijaya Kumar Pathia replied to Sagar P on 15-Sep-08 06:47 AM

Thanks Sujit for your reply. I have followed the way that you have mentioned in the second step and able to run the Power Point Viewer on panel control. but the thing is that in the panel it shows a part of the slide instead of total slide. But when the size of the panel is set to the screen size it shows the total slid.

So is there any way to view the slide in the predefined panel client area??