I have a wpf application that embeds powepoint file into a webBrowser control. I managed to implement that functionality using the below sample code. But whenever i run the ppt file the slide show popups into the screen for a few seconds and then only it embeds into the control. Is there any way to stop this or run it as a background process ?
using System;
using System.Runtime.InteropServices;
using System.Windows;
using Microsoft.Office.Core;
using PPT = Microsoft.Office.Interop.PowerPoint;
namespace WpfApplication1
{
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
[DllImport("User32", CharSet = CharSet.Auto, ExactSpelling = true)]
internal static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndParent);
private void BtnOpenClick(object sender, RoutedEventArgs e)
{
const string pptFilePath = @"E:\Sample.ppt";
var pptApplication = new PPT.Application
{
ShowWindowsInTaskbar = MsoTriState.msoFalse
};
var presentation = pptApplication.Presentations.Open(pptFilePath, MsoTriState.msoCTrue,
MsoTriState.msoTrue, MsoTriState.msoFalse);
var slideShowWindow = presentation.SlideShowSettings.Run();
slideShowWindow.Height = (int)(0.85 * webBrowser1.Height);
slideShowWindow.Width = (int)(0.75 * webBrowser1.Width);
SetParent(new IntPtr(presentation.SlideShowWindow.HWND), webBrowser1.Handle);
}
}
}
I had the same issue and I used this solution by Patrick Reisert. He uses the powerpointviewer and not powerpoint and converts the slide show to a list of bitmaps. It is a comprehensive solution with navigation capabilities.