none
capture the comments of each slide RRS feed

  • Question

  • hello all, I have the following code would like to share and it works perfect.
    What it does, the slide switch must capture the comments in each slide.

    So far I have the slide change event, but I can not capture the comments of each slide


    public partial class ThisAddIn
        {
           
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {


                Application.SlideShowNextSlide +=new PowerPoint.EApplication_SlideShowNextSlideEventHandler(Application_SlideShowNextSlide);
                
                
                
            }

            private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
            {

     

            }

          
            void Application_SlideShowNextSlide(Microsoft.Office.Interop.PowerPoint.SlideShowWindow Wn)
            {
                
             


               catchcomment();
                    
                
            }

            public void catchcomment()

            {

                
                String a;

                foreach (PowerPoint.Slide slide in Globals.ThisAddIn.Application.ActivePresentation.Slides)
                {
                    foreach (PowerPoint.Comment comment in slide.Comments)
                    {

                        a = comment.Text();  // the program tells me that is not callable *************************
                        
                    }
                }

            }





            #region VSTO generated code

            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InternalStartup()
            {
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
            }

            #endregion

        }

    Sunday, August 5, 2012 12:45 AM

Answers

  • When the SlideShowNextSlide event fires, a SlideShowWindow parameter is provided. You can query that. I think this code will work with PowerPoint 2010, and may or may not work with other PowerPoint versions:

    void Application_SlideShowNextSlide(Microsoft.Office.Interop.PowerPoint.SlideShowWindow Wn)
    {
       Microsoft.Office.Interop.PowerPoint.Slide currentSlide = Wn.View.Slide;
       foreach (PowerPoint.Comment comment in currentSlide.Comments)
       {
          MessageBox.Show(comment.Text);
       }
    }
    I think you could work this out from the information on MSDN; Microsoft's documentation of Office object models and hierachies is very good. Should you need to ask future questions, I advise you post them in the General Office for Developers forum, as this type of question

    is not about VSTO.


    • Edited by JosephFox Sunday, August 5, 2012 7:47 PM missed a semi-colon
    • Marked as answer by Andre06 Sunday, August 5, 2012 11:06 PM
    • Unmarked as answer by Andre06 Sunday, August 5, 2012 11:06 PM
    • Marked as answer by Andre06 Sunday, August 5, 2012 11:07 PM
    Sunday, August 5, 2012 7:46 PM
  • works perfect in each slide just shows me the message 2 times

    and I need to display the message once

    pd:what I did in powerpoint 2007

    Do you know how to set up breakpoints? If not, it's simple, at least in Visual Studio....you simply click to the left of the command you want execution to break at. You should then see a big red circle.

    It's worth setting breakpoints to see if the repeated message is the result of the event being called twice, or the result of two identical messages being present in the slide's message collection.

    • Marked as answer by Andre06 Sunday, August 5, 2012 11:28 PM
    Sunday, August 5, 2012 11:17 PM

All replies

  • Re.

     a = comment.Text();  // the program tells me that is not callable *************************
    'Text', in this case, is a property, not a method. So the statement doesn't require brackets at the end.


    • Edited by JosephFox Sunday, August 5, 2012 4:49 PM
    Sunday, August 5, 2012 4:49 PM
  • public void catchcomment()

            {




                foreach (PowerPoint.Slide slide in Globals.ThisAddIn.Application.ActivePresentation.Slides)
                {


                    foreach (PowerPoint.Comment comment in slide.Comments)
                    {



                       MessageBox.Show( comment.Text);



                    }
                }

            }

    this part is already solved
    It prints well, but I printed all the comments and I want to do I print only the slide that I am, I will have some error in foreach?

                                                                                                 
    Sunday, August 5, 2012 7:26 PM
  • When the SlideShowNextSlide event fires, a SlideShowWindow parameter is provided. You can query that. I think this code will work with PowerPoint 2010, and may or may not work with other PowerPoint versions:

    void Application_SlideShowNextSlide(Microsoft.Office.Interop.PowerPoint.SlideShowWindow Wn)
    {
       Microsoft.Office.Interop.PowerPoint.Slide currentSlide = Wn.View.Slide;
       foreach (PowerPoint.Comment comment in currentSlide.Comments)
       {
          MessageBox.Show(comment.Text);
       }
    }
    I think you could work this out from the information on MSDN; Microsoft's documentation of Office object models and hierachies is very good. Should you need to ask future questions, I advise you post them in the General Office for Developers forum, as this type of question

    is not about VSTO.


    • Edited by JosephFox Sunday, August 5, 2012 7:47 PM missed a semi-colon
    • Marked as answer by Andre06 Sunday, August 5, 2012 11:06 PM
    • Unmarked as answer by Andre06 Sunday, August 5, 2012 11:06 PM
    • Marked as answer by Andre06 Sunday, August 5, 2012 11:07 PM
    Sunday, August 5, 2012 7:46 PM
  • joseph thanks for your help, good probe this code

    void Application_SlideShowNextSlide(Microsoft.Office.Interop.PowerPoint.SlideShowWindow Wn)
    {
       Microsoft.Office.Interop.PowerPoint.Slide currentSlide = Wn.View.Slide;
       foreach (PowerPoint.Comment comment in currentSlide.Comments)
       {
          MessageBox.Show(comment.Text);
       }
    }

    works perfect in each slide just shows me the message 2 times

    and I need to display the message once

    pd:what I did in powerpoint 2007




    • Edited by Andre06 Sunday, August 5, 2012 11:10 PM
    Sunday, August 5, 2012 10:19 PM
  • Even on PowerPoint 2007, I would expect that code to show the comments of the slide being changed from. If you want to show the slide being changed to, slightly different code is needed.

    Do you see the comments of the slide being changed from?

    If not, hopefully someone else will respond. Or, or you'll have to wait a couple of days (because I'm in the middle of an Office overhaul, and can't test stuff on my computer right now).

    Sunday, August 5, 2012 11:10 PM
  • works perfect in each slide just shows me the message 2 times

    and I need to display the message once

    pd:what I did in powerpoint 2007

    Do you know how to set up breakpoints? If not, it's simple, at least in Visual Studio....you simply click to the left of the command you want execution to break at. You should then see a big red circle.

    It's worth setting breakpoints to see if the repeated message is the result of the event being called twice, or the result of two identical messages being present in the slide's message collection.

    • Marked as answer by Andre06 Sunday, August 5, 2012 11:28 PM
    Sunday, August 5, 2012 11:17 PM
  • thank youuu was not necessary foreach !!!!!!

    void Application_SlideShowNextSlide(Microsoft.Office.Interop.PowerPoint.SlideShowWindow Wn) { Microsoft.Office.Interop.PowerPoint.Slide currentSlide = Wn.View.Slide; }

    Sunday, August 5, 2012 11:29 PM
  • then I is printing the application, without which I put messagebox, how could it be, without having to print me alone, I need to capture or print only when through a messagebox?
    Monday, August 6, 2012 12:10 AM
  • Assuming you mean literally printing ('printing' is so often used as a metaphor in computing!) have a look at this. It suggests using the System.Drawing and System.Drawing.Printing namespaces.
    Monday, August 6, 2012 8:22 AM