none
Powerpoint slideshow advance slide programatically

    Question

  • Hi,

    I have written a VB.net 2010 Powerpoint addin that needs to be able to advance the slide via a button on it's main form when running the presentation.  The functionality I require is exactly as if you press the space bar while focus is on the slide show window.

    I have tried-

    PowerPointApp.ActivePresentation.SlideShowWindow.View.Next

    But this does not work in excatly the same way, namely when working with several animation sequences on the same slide.

    I am looking into using the API - FindWindow & SendMessage but I do not fully understand the steps to get this to work, or even if it can.

     Or is there another way?

    I am using Visual Studio 2010 RC with Powerpoint 2010 Developer Beta.

    Any help would be greatly appreciated.

    Tuesday, March 23, 2010 11:43 AM

Answers

  • Hello Jeff,

    I tested in both of my PowerPoint 2007 and PowerPoint 2010. In PowerPnt2007 version, the COM Interop codes work fine. It acts as the same effect that pressing space when slides show. In PowerPnt2010, it does not work as the previous version. So this looks like a behavior bug in the RC version. I have submited this issue internally.

    The possible workaround currently are mentioned by you. As to how to find the Silde Show View Window, I used the Spy++ to look into the application's Windows Structure. I find that the Main Window's title differs from versions, but the SildeShowView window always be (window name: "Slide Show",  class name: "paneClassDC"). Since we are in VB.NET programming and creating an in-process addin for PowerPnt, to get the MainWindow's handle, we use the CurrentProcess.MainWindowHandle property

            Dim mwHandle As IntPtr = Process.GetCurrentProcess().MainWindowHandle
            Dim slideShowWindowHandle As IntPtr FindWindEx(mwHandle, 0, "Slide Show", "paneClassDC")

     

    Best regards
    Ji Zhou
    MSDN Subscriber Support in Forum


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Jeff Bowman Monday, March 29, 2010 10:10 AM
    Monday, March 29, 2010 2:49 AM
    Moderator

All replies

  • Thanks for the very quick reply and useful links!

    I got suck with FindWindow - I don't know how to find out the name of the slideshow view window in Powerpoint - will it be different for each version of Powerpoint and/or different depending on the name of the loaded presentation?

    Jeff

    Tuesday, March 23, 2010 12:25 PM
  • Hello Jeff,

    I tested in both of my PowerPoint 2007 and PowerPoint 2010. In PowerPnt2007 version, the COM Interop codes work fine. It acts as the same effect that pressing space when slides show. In PowerPnt2010, it does not work as the previous version. So this looks like a behavior bug in the RC version. I have submited this issue internally.

    The possible workaround currently are mentioned by you. As to how to find the Silde Show View Window, I used the Spy++ to look into the application's Windows Structure. I find that the Main Window's title differs from versions, but the SildeShowView window always be (window name: "Slide Show",  class name: "paneClassDC"). Since we are in VB.NET programming and creating an in-process addin for PowerPnt, to get the MainWindow's handle, we use the CurrentProcess.MainWindowHandle property

            Dim mwHandle As IntPtr = Process.GetCurrentProcess().MainWindowHandle
            Dim slideShowWindowHandle As IntPtr FindWindEx(mwHandle, 0, "Slide Show", "paneClassDC")

     

    Best regards
    Ji Zhou
    MSDN Subscriber Support in Forum


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Jeff Bowman Monday, March 29, 2010 10:10 AM
    Monday, March 29, 2010 2:49 AM
    Moderator
  • Hi Ji,

    Thanks for a thorough answer to my question, it's really appreciated and I have learnt about child windows too!

    I will use this solution for now.

    Kind regards,

    Jeff

    Monday, March 29, 2010 10:12 AM
  • This fault is still present in the final release. Is there any word on when it might be fixed?
    Saturday, November 13, 2010 12:27 AM
  • I think what the issue is, is when you run PowerPoint manually and it looses focus it pauses the slide animations until it regains focus. So running PowerPoint through your app means it doesn't have focus, so a work around I'm using is to trick PowerPoint into thinking it has focus (c#):

    User32.SendMessage(new IntPtr(PowerPointApp.ActivePresentation.SlideShowWindow.HWND), User32.WM_SETFOCUS, IntPtr.Zero, UIntPtr.Zero);
    PowerPointApp.ActivePresentation.SlideShowWindow.View.Next();
    
    public class User32
    {
        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);
    }
    


    Saturday, November 05, 2011 11:52 PM