Click here to Skip to main content
11,577,522 members (50,760 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C#4.0
using System.Diagnostics;
using System.Runtime.InteropServices;
using ppt = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;

   [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
        static extern IntPtr FindWindow(IntPtr ZeroOnly, string lpWindowName);
        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
        [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
        public static extern bool SetWindowText(IntPtr hwnd, String lpString);
        ppt.Presentation presentation;
        Microsoft.Office.Interop.PowerPoint.SlideShowView oSlideShowView;
        bool flag = false;
        public void open(string FileName)
                ppt.Application application;
                // For Display in Panel
                IntPtr screenClasshWnd = (IntPtr)0;
                IntPtr x = (IntPtr)0;
                application = new ppt.Application();
                presentation = application.Presentations.Open(FileName, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
                ppt.SlideShowSettings sst1 = presentation.SlideShowSettings;
                sst1.LoopUntilStopped = Microsoft.Office.Core.MsoTriState.msoCTrue;
                ppt.Slides objSlides = presentation.Slides;
                sst1.LoopUntilStopped = MsoTriState.msoTrue;
                sst1.StartingSlide = 1;
                sst1.EndingSlide = objSlides.Count;
                panel1.Dock = DockStyle.Fill;
                sst1.ShowType = ppt.PpSlideShowType.ppShowTypeKiosk;
                ppt.SlideShowWindow sw = sst1.Run();
                oSlideShowView = presentation.SlideShowWindow.View;
                IntPtr pptptr = (IntPtr)sw.HWND;
                SetParent(pptptr, panel1.Handle);

            catch (Exception)

        private void Form3_Load(object sender, EventArgs e)
            string FileName = "D:\\test.pptx";
        private void timer1_Tick(object sender, EventArgs e)

Here I m Trying to Play Power Point in a Window Panel.
its playing power point file in Panel but problem is that first it play full screen within fraction of seconds it continue playing in Panel.
but i need to play directly on panel.
Please Help if any one knows.
Posted 24-Feb-13 20:21pm
Edited 24-Feb-13 23:39pm
romanpetrov at 26-Mar-13 6:14am
I have exactly the same problem...
romanpetrov at 27-Mar-13 4:25am
Doing some research, I found that this problem not appears in PowerPoint 2013, only in previous versions of PowerPoint.
rakesh bairi at 28-Mar-13 1:39am
In my case I am developing Windows application installed on Client Side,Code should be Independent of Microsoft office,
romanpetrov at 28-Mar-13 8:51am
Actually, your code DEPENDS on PowerPoint version. In PowerPoint 2010, after your call ppt.SlideShowWindow sw = sst1.Run(); PowerPoint always shows slide at fullscreen. You can check this with presentation having a transition on its first slide. In PowerPoint 2013 this problem not occurs.
rakesh bairi at 30-Mar-13 9:32am
Thanks for answer I have one doubt should i have to use power point 2013 assembly in my code ?because in my Development machine i have office 2010
romanpetrov at 16-Apr-13 7:42am
If you install Office 2013, the issue should be gone. But I still not have any solution for PowerPoint 2010..
rakesh bairi at 17-Apr-13 3:18am
thanks i will try with office 2013.
rakesh bairi at 9-Apr-13 3:05am
Please help me not got solution until now :(
rakesh bairi at 3-May-13 10:25am
thanks @romanpetrov finally got solution
GeorgeHLord at 26-May-14 17:40pm
Hi , I´m facing the same problem. But I have to make it run not just for PowerPoint 2013.
@rakeshbairi did you find another way to embed ppt in WPF?

best regards

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 180
1 OriginalGriff 115
2 Richard MacCutchan 100
3 Abhinav S 90
4 Peter Leow 80
0 OriginalGriff 820
1 Sergey Alexandrovich Kryukov 681
2 Abhinav S 528
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 375

Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100