News Category

C#/VB.NET: Add, Read or Delete Speaker Notes in PowerPoint

2022-08-22 08:53:00 Written by  support iceblue
Rate this item
(0 votes)

Speaker notes in PowerPoint are specific contents that appear only on the presenter's monitor when presenting the slideshow. They can remind the presenter of the important points that he needs to explain to the audience. In this article, we will demonstrate how to add, read or delete speaker notes in PowerPoint in C# and VB.NET using Spire.Presentation for .NET.

Install Spire.Presentation for .NET

To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Presentation

Add Speaker Notes in PowerPoint in C# and VB.NET

The following are the main steps to add speaker notes to a PowerPoint document:

  • Create a Presentation instance and load a PowerPoint document using Presentation.LoadFromFile() method.
  • Get the desired slide that you want to add speaker notes to through Presentation.Slides[slideIndex] property.
  • Add a notes slide to the slide using ISlide.AddNotesSlides() method.
  • Create a TextParagraph instance.
  • Set text for the paragraph through TextParagraph.Text property, then append the paragraph to the notes slide using NotesSlide.NotesTextFrame.Paragraphs.Append() method.
  • Save the result document using Presentation.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace AddSpeakerNotes
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Load a PowerPoint document
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("Sample.pptx");

            //Get the first slide
            ISlide slide = ppt.Slides[0];
            //Add a notes slide
            NotesSlide notesSlide = slide.AddNotesSlide();

            //Add a paragraph to the notes slide
            TextParagraph paragraph = new TextParagraph();
            paragraph.Text = "Tips for making effective presentations:";
            notesSlide.NotesTextFrame.Paragraphs.Append(paragraph);

            //Add a paragraph to the notes slide
            paragraph = new TextParagraph();
            paragraph.Text = "Use the slide master feature to create a consistent and simple design template.";
            notesSlide.NotesTextFrame.Paragraphs.Append(paragraph);

            //Add a paragraph to the notes slide
            paragraph = new TextParagraph(); 
            paragraph.Text = "Simplify and limit the number of words on each screen.";
            notesSlide.NotesTextFrame.Paragraphs.Append(paragraph);

            //Add a paragraph to the notes slide
            paragraph = new TextParagraph();
            paragraph.Text = "Use contrasting colors for text and background.";
            notesSlide.NotesTextFrame.Paragraphs.Append(paragraph);

            //Set the bullet type and bullet style for specific paragraphs on the notes slide 
            for (int i = 2; i < notesSlide.NotesTextFrame.Paragraphs.Count;i++)
            {
                notesSlide.NotesTextFrame.Paragraphs[i].BulletType = TextBulletType.Numbered;
                notesSlide.NotesTextFrame.Paragraphs[i].BulletStyle = NumberedBulletStyle.BulletArabicPeriod;
            }

            //Save the result document
            ppt.SaveToFile("SpeakerNotes.pptx", FileFormat.Pptx2013);
        }
    }
}

C#/VB.NET: Add, Read or Delete Speaker Notes in PowerPoint

Read Speaker Notes in PowerPoint in C# and VB.NET

The following are the steps to read the speaker notes on a PowerPoint slide:

  • Create a Presentation instance and load the PowerPoint document using Presentation.LoadFromFile() method.
  • Get the desired slide that you want to read speaker notes from through Presentation.Slides[slideIndex] property.
  • Get the notes slide from the slide through ISlide.NotesSlide property.
  • Get the speaker notes from the notes slide through NotesSlide.NotesTextFrame.Text property.
  • Create a StringBuilder instance.
  • Append the speaker notes to the string builder, then write them into a .txt file.
  • C#
  • VB.NET
using Spire.Presentation;
using System.Text;
using System.IO;

namespace ReadSpeakerNotes
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Load the PowerPoint document
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("SpeakerNotes.pptx");

            //Get the first slide
            ISlide slide = ppt.Slides[0];           

            //Get the notes slide from the first slide
            NotesSlide notesSlide = slide.NotesSlide;
            //Get the speaker notes from the notes slide
            string notes = notesSlide.NotesTextFrame.Text;
            //Create a StringBuilder instance
            StringBuilder sb = new StringBuilder();
            //Append the speaker notes to the string builder
            sb.AppendLine(notes);
            
            //Save to .txt file
            File.WriteAllText("SpeakerNotes.txt", sb.ToString());
        }
    }
}

C#/VB.NET: Add, Read or Delete Speaker Notes in PowerPoint

Delete Speaker Notes in PowerPoint in C# and VB.NET

The following are the steps to delete speaker notes from a PowerPoint slide:

  • Create a Presentation instance and load the PowerPoint document using Presentation.LoadFromFile() method.
  • Get the desired slide that you want to delete speaker notes from through Presentation.Slides[slideIndex] property.
  • Get the notes slide from the slide through ISlide.NotesSlide property.
  • Delete a specific speaker note from the notes slide using NotesSlide.NotesTextFrame.Paragraphs.RemoveAt(paragraphIndex) method or delete all the speaker notes from the notes slide using NotesSlide.NotesTextFrame.Paragraphs.Clear() method.
  • Save the result document using Presentation.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Presentation;
using System.Text;
using System.IO;

namespace DeleteSpeakerNotes
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Load the PowerPoint document
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("SpeakerNotes.pptx");

            //Get the first slide
            ISlide slide = ppt.Slides[0];
            //Get the notes slide from the slide
            NotesSlide notesSlide = slide.NotesSlide;

            //Remove a specific speaker note from notes slide
            //notesSlide.NotesTextFrame.Paragraphs.RemoveAt(1);

            //Remove all the speaker notes from notes slide
            notesSlide.NotesTextFrame.Paragraphs.Clear();

            //Save the result document
            ppt.SaveToFile("DeleteSpeakerNotes.pptx", FileFormat.Pptx2013);

        }
    }
}

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Additional Info

  • tutorial_title:
Last modified on Monday, 22 August 2022 04:57