Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerPoint Notes in C#

Tags:

c#

powerpoint

I want to read the notes of a PowerPoint Slide in C#. Following Snippet works for me.

slide.NotesPage.Shapes[2].TextFrame.TextRange.Text

However, this doesn't work for some presentations. Then it throws an "Out of range" exception.

What ist the meaning of index 2? Are there any alternative to do this?

like image 889
Julian Hinderer Avatar asked Jun 06 '11 13:06

Julian Hinderer


People also ask

Can you take notes in PowerPoint?

Taking Notes on PowerPoint Slides This can be done electronically by using the “Click to add notes” feature on each slide, or by printing the PowerPoint presentation as “Handouts” with lines next to each slide for your own written comments.

What are PowerPoint notes called?

What are speaker notes in PowerPoint? Speaker notes in PowerPoint help presenters recall important points, such as key messages or stats, as they give a presentation. The speaker note panel lives at the bottom of your screen in Normal view, although some users may have this section hidden.

How do I convert a PowerPoint to good notes?

Importing PowerPoint presentations from within GoodNotesTap the New… icon (large plus icon) in the Documents tab and choose Import, then tap a file to start the import!


2 Answers

You can't assume that the notes text placeholder will be at any specific index or even that it'll have a specific name. Here's a simple function in VBA that returns the notes text placeholder for a slide:

Function NotesTextPlaceholder(oSl As Slide) As Shape

Dim osh As Shape

For Each osh In oSl.NotesPage.Shapes

    If osh.Type = msoPlaceholder Then
        If osh.PlaceholderFormat.Type = ppPlaceholderBody Then
            ' we found it
            Set NotesTextPlaceholder = osh
            Exit Function
        End If
    End If

Next

End Function

like image 168
Steve Rindsberg Avatar answered Oct 24 '22 08:10

Steve Rindsberg


It means that you are trying to access the third element of the slide.NotesPage.Shapes collection. If the collection has 2 elements or less, the exception is thrown because the element at the specified index 2 could not be accessed since it doesn't exist — you simply cannot retrieve a collection's third element if it doesn't have one.

(The index is zero-based, meaning that the first element is given the index 0, the second one is given the index 1 and so on. Thus, the greatest possible index of a collection with N elements is N-1.)

like image 41
Marius Schulz Avatar answered Oct 24 '22 09:10

Marius Schulz