This is my code for a powerpoint add-on writtin in C# visual studio to pull out hidden text (which will be text in the notes of the slide) in each slide as the slide is visited
in a slideshow and convert it to audio. First is to pull out the text in the notes when the slide is visited and display as a message which isn't quite working in the code below. At the moment when the code is ran it just opens powerpoint and nothing
else seems to be working. There might be somewhere I'm going wrong. I've added the for loop in the events to try to iterate through the shapes to find the one which is the notes placeholder.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using System.Speech.Synthesis;
namespace FirstPowerPointAddIn
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
/* //connect the Application_PresentationNewSlide event handler with the PresentationNewSlide event.
this.Application.PresentationNewSlide +=
new PowerPoint.EApplication_PresentationNewSlideEventHandler(
Application_PresentationNewSlide); */
SpeechSynthesizer synth = new SpeechSynthesizer();
// Configure the audio output.
synth.SetOutputToDefaultAudioDevice();
PowerPoint.Application oPowerPoint = null;
try
{
oPowerPoint.SlideShowBegin += oPowerPoint_SlideShowBegin;
oPowerPoint.SlideShowNextSlide += oPowerPoint_SlideShowNextSlide;
}
catch(Exception)
{
Console.WriteLine("error");
}
}
private void ThisAddIn_Shutdown(object Pender, System.EventArgs e)
{
}
private void oPowerPoint_SlideShowBegin(SlideShowWindow Wn)
{
for (int i = 0; i < Wn.View.Slide.NotesPage.Shapes.Count; i++)
{
// If the slide has notes, get the notes
if (Wn.View.Slide.HasNotesPage == Microsoft.Office.Core.MsoTriState.msoTrue)
{
if (Wn.View.Slide.NotesPage.Shapes[i].TextFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
System.Windows.Forms.MessageBox.Show(Wn.View.Slide.NotesPage.Shapes[i].TextFrame.TextRange.Text);
}
}
}
void oPowerPoint_SlideShowNextSlide(PowerPoint.SlideShowWindow Wn)
{
for (int i = 0; i < Wn.View.Slide.NotesPage.Shapes.Count; i++)
{
if (Wn.View.Slide.HasNotesPage == Microsoft.Office.Core.MsoTriState.msoTrue)
{
if (Wn.View.Slide.NotesPage.Shapes[i].TextFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
System.Windows.Forms.MessageBox.Show(Wn.View.Slide.NotesPage.Shapes[i].TextFrame.TextRange.Text);
}
}
}
#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
}
}