none
PowerPoint - SlideShowNextBuild not firing ? RRS feed

  • Question

  • Powerpoint Automation in C#

    My sample code has the SlideShowNextSlideHandler trace but not the

    MySlideShowNextBuildHandler  trace, as displayed slides are changed under the timer.

    >> Anyone else who has had this issue and knows the solution ?

     ShowType = PowerPoint.PpSlideShowType.ppShowTypeWindow; or Speaker

             [ComVisibleAttribute(false)]
            public delegate void EApplication_SlideShowNextSlideEventHandler(
                PowerPoint.SlideShowWindow Wn
            );

            [ComVisibleAttribute(false)]
            public delegate void EApplication_SlideShowNextBuildEventHandler(
                PowerPoint.SlideShowWindow Wn
            );

    ...

    static void MySlideShowNextSlideHandler(PowerPoint.SlideShowWindow Wn) { Debug.WriteLine(string.Format("MySlideShowNextSlideHandler Slide {0}", Wn.View.CurrentShowPosition)); } static void MySlideShowNextBuildHandler(PowerPoint.SlideShowWindow Wn) { Debug.WriteLine(string.Format("MySlideShowNextBuildHandler Slide {0}", Wn.View.CurrentShowPosition)); } ...... ppApp.SlideShowNextSlide += new PowerPoint.EApplication_SlideShowNextSlideEventHandler(MySlideShowNextSlideHandler); ppApp.SlideShowNextBuild += new PowerPoint.EApplication_SlideShowNextBuildEventHandler(MySlideShowNextBuildHandler);

    Thanks


    Tuesday, April 3, 2012 1:00 PM

Answers

  • Hi Greg,
    Please do examine the content in the articles at the URLs above. To avoid the coding issue please consider modifying you program to use the classes for PowerPoint provided in .NET Framework, once you add a reference to PowerPoint to your project. Next please see the following article to see examples of coding Event Handling Delegate declaration and coding using C#, VB .NET, and C++ when writing managed code. This works with the .NET framework 2.0, 3.0, 3.5, and 4.0. Please install 4.0 if you don’t have it already

    PropertyChangedEventHandler Delegate (System.ComponentModel)
    http://msdn.microsoft.com/en-us/library/system.componentmodel.propertychangedeventhandler.aspx

    Click the link in the page to jump to code examples for ‘Events and Delegates” The event in the code is ‘PropertyChanged”. The form of declaration applies to any event. You can replace the ‘PropertyChanged’ with SlideShowNextBuild.
    You need to have a reference to PowerPoint in your project references
    Please modify your program and then run it in debug mode Do you see the issue when running in debug mode, attaching your project to a presentation with multiple slides, and clicking through the presentation?
    Regards,
    Senior Technical Support Lead
    Chris Jensen


    Chris Jensen

    • Marked as answer by Greg B Roberts Wednesday, April 18, 2012 1:00 PM
    Tuesday, April 17, 2012 9:54 PM
    Moderator

All replies

  • Hi Greg B Roberts,
    Thank you for posting.
    I will help you involve others to help you. There might be some delay about the response. Appreciate your patience.
    Best Regards,

    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, April 4, 2012 8:20 AM
  • Hi Bruce,

    You asked "Anyone else who has had this issue and knows the solution ?" Since nobody has responded I can only help you debug the issue on your system, or determine a workaround.

    The event occurs upon mouse-click or timing animation, but before the animated object becomes visible. Do you see the issue when running your code in debug mode, attaching your project to a presentation with multiple slides, and clicking through the presentation?

    Do you have the .NET Framework  3.5 and/or 4.0? If not consider installing .NET 4.0 Framework

    Apropos of that recommendation, please see the recommendation at the end of this article:
    ApplicationClass.SlideShowNextBuild Event (Microsoft.Office ...
    http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.applicationclass.slideshownextbuild.aspx

    Your code contains delegate signatures for EApplication
    methods. Please see the following :
    EApplication.SlideShowNextBuild Method (Microsoft.Office.Interop ...
    http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.eapplication.slideshownextbuild.aspx

    and click on the link to EApplication Members. The definitions for all members
    say “not intended to be used in your code”.

    The article at the link below is true for PowerPoint 2002, and the concept may be used to track events as fired in PowerPoint 2010.
    308825  How to handle PowerPoint events with Visual C# .NET
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;308825

    Please let us know if following the content listed above helps you answer your query.
    Thanks.
    Regards,
    Chris Jensen
    Senior Technical Support Lead

    Chris Jensen

    Wednesday, April 4, 2012 8:39 PM
    Moderator
  • Thanks Chris

    A quick reply before i scan the referenced material.

    - I tried full screen and windowsed screen in Powerpoint 2010 under vs2010

    - slides have a time set for all slides, so tried with this as well as page down, click

    - I always get the SlideNext, never the slidebuild so can't see how i can be missing a .net framework

    - Using .NET 4

    - This code is in an app driving the pptx show

    Later :

    Code above used these links provided however i don't understand the

    [ClassInterfaceAttribute()]
    [GuidAttribute("91493441-5A91-11CF-8700-00AA0060263B")]
    public class ApplicationClass : _Application, 
    	Application, EApplication_Event
    

    reference. I do not have _Application, Application, EApplication_Event in my code

    => Program runs, shows slides, these change, "

    "MySlideShowNextSlideHandler Slide 1" messages come out, no MySlideShowNextBuildHandler"

    Greg

    Fuller code snippet

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;
    using Microsoft.Office.Core;
    using PowerPoint = Microsoft.Office.Interop.PowerPoint;
    using System.Threading;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
    namespace SlideShowControl
    {
        static class Program
        {
            const string    DefaultFile = @"C:\Slideshow_Powerpoint\OO_Syd_WideScreen.pptx";
            const int       SleepTimeMs = 200;
            const int       MaxPauseSeconds = 120;
            static bool     bTerminateThread;
            static string   pptPath;
            [ComVisibleAttribute(false)]
            public delegate void EApplication_SlideShowNextSlideEventHandler(
                PowerPoint.SlideShowWindow Wn
            );
            [ComVisibleAttribute(false)]
            public delegate void EApplication_SlideShowNextBuildEventHandler(
                PowerPoint.SlideShowWindow Wn
            );
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main(string[] args)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
            static void MySlideShowNextSlideHandler(PowerPoint.SlideShowWindow Wn)
            {
                Debug.WriteLine(string.Format("MySlideShowNextSlideHandler Slide {0}", Wn.View.CurrentShowPosition));
            }
            static void MySlideShowNextBuildHandler(PowerPoint.SlideShowWindow Wn)
            {
                Debug.WriteLine(string.Format("MySlideShowNextBuildHandler Slide {0}", Wn.View.CurrentShowPosition));
            }
            static private void PowerpointThread()
            {
                bTerminateThread = false;
                PowerPoint.Application ppApp = new PowerPoint.Application();
                ppApp.Visible = MsoTriState.msoTrue;
                ppApp.SlideShowNextSlide += new PowerPoint.EApplication_SlideShowNextSlideEventHandler(MySlideShowNextSlideHandler);
                ppApp.SlideShowNextBuild += new PowerPoint.EApplication_SlideShowNextBuildEventHandler(MySlideShowNextBuildHandler);
                PowerPoint.Presentations ppPresens = ppApp.Presentations;
                PowerPoint.Presentation objPres = ppPresens.Open(pptPath, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
                PowerPoint.Slides objSlides = objPres.Slides;
                PowerPoint.SlideShowSettings objSSS;
                //Run the Slide show
                objSSS = objPres.SlideShowSettings;
                objSSS.StartingSlide = 1;
                //objSSS.ShowType = PowerPoint.PpSlideShowType.ppShowTypeSpeaker;  
                objSSS.ShowType = PowerPoint.PpSlideShowType.ppShowTypeWindow;  
                objSSS.EndingSlide = objSlides.Count;
                PowerPoint.SlideShowWindow presWin = objSSS.Run();




    Wednesday, April 4, 2012 10:02 PM
  • Hi Greg,

    You reply "I do not have ... EApplication in my code."

    Your code does start with these:
      [ComVisibleAttribute(false)]
           
    public delegate void EApplication_SlideShowNextSlideEventHandler(
               
    PowerPoint.SlideShowWindow Wn
           
    );
           
    [ComVisibleAttribute(false)]
           
    public delegate void EApplication_SlideShowNextBuildEventHandler(
               
    PowerPoint.SlideShowWindow Wn
           
    );

    Regards,
    Chris Jensen
    Senior Technical Support Lead


    Chris Jensen

    Thursday, April 5, 2012 1:58 PM
    Moderator
  • Chris

    My code which "works" (except for the issue) has no Guuid, no _Application, direct Application but does via Powerpoint.Appllication,

    Mores the point if i include this i can't compile unless this is meant to replace the "program" class, then it makes more sense. Even when i do this , the compiler is not happy because it does not know what the items are to the right of the :

    SO i suppose some extra context is missing from the help, but obvious to someone to someone who has the background to know what they are getting at.

    So i suppose the question i need to ask, is there a reason i should be using the lines belowin addition to below ?

    [GuidAttribute("91493441-5A91-11CF-8700-00AA0060263B")]
    public class ApplicationClass : _Application,
    Application, EApplication_Event

    As both items are EApplication events, i can't understand why one works and not the other?

    regards



    Thursday, April 5, 2012 11:05 PM
  • Hi Greg,
    Please do examine the content in the articles at the URLs above. To avoid the coding issue please consider modifying you program to use the classes for PowerPoint provided in .NET Framework, once you add a reference to PowerPoint to your project. Next please see the following article to see examples of coding Event Handling Delegate declaration and coding using C#, VB .NET, and C++ when writing managed code. This works with the .NET framework 2.0, 3.0, 3.5, and 4.0. Please install 4.0 if you don’t have it already

    PropertyChangedEventHandler Delegate (System.ComponentModel)
    http://msdn.microsoft.com/en-us/library/system.componentmodel.propertychangedeventhandler.aspx

    Click the link in the page to jump to code examples for ‘Events and Delegates” The event in the code is ‘PropertyChanged”. The form of declaration applies to any event. You can replace the ‘PropertyChanged’ with SlideShowNextBuild.
    You need to have a reference to PowerPoint in your project references
    Please modify your program and then run it in debug mode Do you see the issue when running in debug mode, attaching your project to a presentation with multiple slides, and clicking through the presentation?
    Regards,
    Senior Technical Support Lead
    Chris Jensen


    Chris Jensen

    • Marked as answer by Greg B Roberts Wednesday, April 18, 2012 1:00 PM
    Tuesday, April 17, 2012 9:54 PM
    Moderator