Embed instance of Powerpoint Viewer 2007 on a form


  • Can someone please show me how to embed and control an instance of POwerpoint Viewer 2007 on my form ?

    I am trying to display powerpoint slides on a form when ms-powerpoint is not available on end users system.

    Appreciate any help.

    using VB.NET Express 2008 on WinXP
    Wednesday, July 23, 2008 11:56 AM

All replies

  • said:

    I am trying to display powerpoint slides on a form when ms-powerpoint is not available on end users system.

    Hi Xancholy,

    Here is one free PowerPoint Viewer ActiveX Control for you to try viewing the powerpoint file (ppt, pps file) in VB.NET application.
    After you download and install the powerpointviewerdemosetup.exe from above link, the ActiveX control has been registered, you will find VB.NET code sample under default installation path C:\Program Files\PowerPoint Viewer ActiveX Control\Examples\VB.Net.

    The activeX control will locate at C:\Program Files\PowerPoint Viewer ActiveX Control\PowerPointViewer.ocx.

    You can manually register the ActiveX control using Regsvr32.exe tool

    Add the ActiveX control to Toolbox:
    Right-click Toolbox -> Choose items -> COM components -> Locate
    PowerPoint Viewer ActiveX Control and add it
    Then you can drag&drop it onto your Form


    Some important methods of the PowerPoint Viewer ActiveX Control:

    When you distribute your application to end users, you need to include the PowerPointViewer.ocx file to your project, and tell end users to manually register the ActiveX control using Regsvr32.exe tool, or directly install powerpointviewerdemosetup.exe.

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best regards,
    Martin Xie

    Tuesday, July 29, 2008 10:16 AM
  • Thank you Martin. I have purchased that powerpoint viewer activex and it does not work on any system where MS-POwerpoint is not installed.

    I am trying to display powerpoint slides on a form when ms-powerpoint is not available on end users system.

    Therefore I am now trying to embed Powerpoint Viewer 2007 on my form and automate it.

    Can you help ?

    using VB.NET Express 2008 on WinXP
    Tuesday, July 29, 2008 8:48 PM
  • Hi

    I'm working on a simular project/problem as described in the first post. Have you found any solution on how to use PowerPoint Viewer in a VB form?

    Thanks :)
    Wednesday, July 30, 2008 9:26 AM
  • Hi,

    I am trying to make a simple powerpoint 2003 / 2007 player. So far i have come up with the following: -

    ublic Sub PowerPoint(ByVal Path As String
            View.EnableRaisingEvents = False 
            View.StartInfo.WindowStyle = ProcessWindowStyle.Maximized 
            View.StartInfo.CreateNoWindow = True 
            ' Used in development for EXE called from debug folder.  
            View.StartInfo.FileName = "C:\Program Files\Microsoft Office\Office12\pptview.exe" 
            View.StartInfo.Arguments = "/S" + Chr(34) + Path + Chr(34) 
            View.StartInfo.UseShellExecute = False 
        End Sub 

    Which uses the development debugging process to play the files using the free microsoft powerpoint viewer, the only problem is it does not handle errors.

    Is there a better way of doing this?

    Is the following package from microsoft any good? i think is only allows you to embedd office files, i donlt think it can play office files that a user selects.

    The ActiveX Control DSOFramer.ocx is supplied by Microsoft, which allows developers to embed Office files for in-place editing and viewing while giving more control than the WebBrowser control.

    Detail: the DsoFramer_KB311765_x86.exe package.


    • Proposed as answer by Dora9 Wednesday, September 02, 2009 2:20 PM
    Monday, September 08, 2008 11:32 AM
  • I have been trying to figure out how to do the same....I've used the technique you have above, but where I'm stuck is resizing the viewer to conform to the second monitor's resolution.

    Has anyone tried to do this?
    • Edited by jdchitt Wednesday, October 22, 2008 4:56 AM
    Wednesday, October 22, 2008 4:55 AM
  • Have you figured out how to embed a 2007 Viewer into you application? I need to do the same thing.

    I have had success using dsoFramer, but that requires that Office be installed on the same machine. I now have a requirement to display Office 2007 documents on a form inside my application without having Office 2007 installed. The viewers (Word, Excel, PowerPoint) all work, but they are desktop apps. How can I embed them within a .NET (C#) Windows Forms application?

    Friday, June 26, 2009 8:18 PM
  • i'd like some help with displaying powerpoint viewer on a second monitor
    Wednesday, September 02, 2009 12:00 PM
  • Hi,

    Sorry i have not tried the code on two monitors, although the code above does not allow specific monitors to be selected as there is no command line argument (which is what the above code is doing) for this in PP View. Please see:-

    to do this you will need to embed office into your application or buy a third party activex component if one exists.

    Wednesday, September 02, 2009 2:26 PM
  • You can move PPView to another monitor with the following c# code:

    [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
    public static extern bool SetWindowPos(int hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
    var screen = System.Windows.Forms.Screen.AllScreens.OrderBy(s => s.Primary).First();
    const uint SWP_NOACTIVATE = 0x0010;
    const int HWND_TOP = 0;
    SetWindowPos((int)View.MainWindowHandle, HWND_TOP, screen.WorkingArea.Left, screen.WorkingArea.Top, screen.WorkingArea.Width, screen.WorkingArea.Height, SWP_NOACTIVATE);

    And to send key presses such as "5\n" to go to the 5th slide:

    [return: MarshalAs(UnmanagedType.Bool)]
    public static extern bool SetForegroundWindow(IntPtr hWnd);
    SetForegroundWindow(new System.Windows.Interop.WindowInteropHelper(System.Windows.Application.Current.MainWindow).Handle); //wpf app
    The only problem I can't work around is that animations pause when I set focus back to my app from PowerPoint Viewer.

    Saturday, July 31, 2010 4:48 AM
  • Good news, I managed to work around the issue of needing the slideshow window to have focus for SendKeys and animations to work. The answer is to use SendMessage which allows you to send key strokes to the window you specify (SendKeys only sends keys to the window that currently has focus) and to send WM_SETFOCUS which is a windows message sent to the application after it has focus but we send it even though it doesn't have focus to trick it into getting animations to work. To know what to set lParam to in SendMessage function I downloaded Visual Studio Trial to get spy++ since express doesn't have it to find out what values make up the bits for lParam with the WM_KEYDOWN message and to find out the name of the window the keystrokes need to be sent to for FindWindowEx (the value in code below is for PPT Viewer 2010 fullscreen).

    public const uint WM_KEYUP = 0x0101;
    public const uint WM_KEYDOWN = 0x0100;
    public const uint WM_SETFOCUS = 0x0007;
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, UIntPtr lParam);
    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr PostMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, UIntPtr lParam);
    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
    SendMessage(View.MainWindowHandle, WM_SETFOCUS, IntPtr.Zero, UIntPtr.Zero);
    IntPtr pane = User32.FindWindowEx(View.MainWindowHandle, IntPtr.Zero, "paneClassDC", "Slide Show");
    PostMessage(pane, WM_KEYDOWN, new IntPtr((int)'N'), new UIntPtr(0x310001));
    PostMessage(pane, WM_KEYUP, new IntPtr((int)'N'), new UIntPtr(0xC0310001));

    Sunday, August 01, 2010 5:03 AM
  • Hi, I have a simmilar project, only I am trying to view ppt from an access database, it gives me the error cant convert binary to string when I pass the binary file to the loadfile method of the  PowerPoint Viewer ActiveX Control, from file it works perfectly though! anyone have any ideas how I can overcome this problem
    Thursday, February 24, 2011 1:33 AM