Python: Add, Read or Delete Speaker Notes in PowerPoint

Speaker notes in PowerPoint play a crucial role in enhancing the presenter's delivery and ensuring a seamless presentation experience. They can be added to individual slides to provide valuable guidance, reminders, and supplementary information for the presenter. Unlike the content displayed on the slides, speaker notes are typically not visible to the audience during the actual presentation. In this article, we'll explain how to add, read or delete speaker notes in a PowerPoint presentation in Python using Spire.Presentation for Python.

Install Spire.Presentation for Python

This scenario requires Spire.Presentation for Python and plum-dispatch v1.7.4. They can be easily installed in your Windows through the following pip command.

pip install Spire.Presentation

If you are unsure how to install, please refer to this tutorial: How to Install Spire.Presentation for Python on Windows

Add Speaker Notes to PowerPoint in Python

Spire.Presentation for Python provides the ISlide.AddNotesSlides() method to add notes to a PowerPoint slide. The detailed steps are as follows.

  • Create a Presentation object.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Get the slide that you want to add notes to using Presentation.Slides[index] property.
  • Add a notes slide to the slide using ISlide.AddNotesSlides() method.
  • Create TextParagraph objects and set text for the paragraphs using TextParagraph.Text property, then add the paragraphs to the notes slide using NotesSlide.NotesTextFrame.Paragraphs.Append() method.
  • Save the resulting presentation using Presentation.SaveToFile() method.
  • Python
from spire.presentation.common import *
from spire.presentation import *

# Create a Presentation object
ppt = Presentation()
# Load a PowerPoint presentation
ppt.LoadFromFile("Sample.pptx")

# Get the first slide
slide = ppt.Slides[0]

# Add a notes slide to the slide
notesSlide = slide.AddNotesSlide()

# Add 4 paragraphs to the notes slide
paragraph = TextParagraph()
paragraph.Text = "Tips for making effective presentations:"
notesSlide.NotesTextFrame.Paragraphs.Append(paragraph)

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

paragraph = TextParagraph()
paragraph.Text = "Simplify and limit the number of words on each screen."
notesSlide.NotesTextFrame.Paragraphs.Append(paragraph)

paragraph = TextParagraph()
paragraph.Text = "Use contrasting colors for text and background."
notesSlide.NotesTextFrame.Paragraphs.Append(paragraph)

# Set bullet type and style for specific paragraphs
for i in range(1, notesSlide.NotesTextFrame.Paragraphs.Count):
    notesSlide.NotesTextFrame.Paragraphs[i].BulletType = TextBulletType.Numbered
    notesSlide.NotesTextFrame.Paragraphs[i].BulletStyle = NumberedBulletStyle.BulletArabicPeriod

# Save the resulting presentation
ppt.SaveToFile("AddSpeakerNotes.pptx", FileFormat.Pptx2016)
ppt.Dispose()

Python: Add, Read or Delete Speaker Notes in PowerPoint

Read Speaker Notes in PowerPoint in Python

To read the text content of the notes, you can use the NotesSlide.NotesTextFrame.Text property. The detailed steps are as follows.

  • Create a Presentation object.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Get the slide that you want to read notes from using Presentation.Slides[index] property.
  • Get the notes slide of the slide using ISlide.NotesSlide property.
  • Get the text content of the notes slide using NotesSlide.NotesTextFrame.Text property.
  • Write the text content into a text file.
  • Python
from spire.presentation.common import *
from spire.presentation import *

# Create a Presentation object
ppt = Presentation()
# Load a PowerPoint presentation
ppt.LoadFromFile("AddSpeakerNotes.pptx")

# Get the first slide
slide = ppt.Slides[0]

# Get the notes slide of the slide
notesSlide = slide.NotesSlide

# Get the text content of the notes slide
notes = notesSlide.NotesTextFrame.Text

# Write the text content to a text file
with open("Notes.txt", 'w') as file:
    file.write(notes)

ppt.Dispose()

Python: Add, Read or Delete Speaker Notes in PowerPoint

Delete Speaker Notes from PowerPoint in Python

You can delete a specific paragraph of note or delete all the notes from a slide using the NotesSlide.NotesTextFrame.Paragraphs.RemoveAt(index) or NotesSlide.NotesTextFrame.Paragraphs.Clear() method. The detailed steps are as follows.

  • Create a Presentation object.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Get the slide that you want to delete notes from using Presentation.Slides[index] property.
  • Get the notes slide of the slide using ISlide.NotesSlide property.
  • Delete a specific paragraph of note or delete all the notes from the notes slide using the NotesSlide.NotesTextFrame.Paragraphs.RemoveAt(index) or NotesSlide.NotesTextFrame.Paragraphs.Clear() method.
  • Save the resulting presentation using Presentation.SaveToFile() method.
  • Python
from spire.presentation.common import *
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()
# Load a PowerPoint presentation
presentation.LoadFromFile("AddSpeakerNotes.pptx")

# Get the first slide
slide = presentation.Slides[0]

# Get the notes slide of the slide
notesSlide = slide.NotesSlide

# Remove a specific paragraph of note from the notes slide
# notesSlide.NotesTextFrame.Paragraphs.RemoveAt(1)

# Remove all the notes from the notes slide
notesSlide.NotesTextFrame.Paragraphs.Clear()

# Save the resulting presentation
presentation.SaveToFile("DeleteSpeakerNotes.pptx", FileFormat.Pptx2013)
presentation.Dispose()

Python: Add, Read or Delete Speaker Notes in PowerPoint

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.