[C# Helper]
Index Books FAQ Contact About Rod
[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[Beginning Software Engineering]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: Use VBA to extract notes form a PowerPoint presentation

[Use VBA to extract notes form a PowerPoint presentation]

When I record screencasts, I sometimes use PowerPoint, and I would like to extract the notes so I can make a script to read. You might think that would be a standard feature of PowerPoint, but you'd be wrong. It's no only not a pre-built feature, but the objects that you need to use are particularly well hidden.

This VBA code displays the presentation's notes in the Immediate window. Then you can copy and paste them into Word or some other program to format and print them.

Sub ExtractNotes() Dim a_slide As Slide Dim a_shape As Shape For Each a_slide In ActivePresentation.Slides For Each a_shape In a_slide.NotesPage.Shapes If a_shape.PlaceholderFormat.Type = ppPlaceholderBody Then If a_shape.HasTextFrame Then If a_shape.TextFrame.HasText Then Debug.Print "***** " & CStr(a_slide.SlideIndex) & " *****" Debug.Print a_shape.TextFrame.TextRange.Text End If End If End If Next a_shape Next a_slide End Sub

The code loops through the active presentation's slides. For each slide, it loops through the slide's notes page shapes.

If a shape has type ppPlaceholderBody, and it has a text frame, and that frame is holding text, then the subroutine prints the slide's index followed by the text.

You could modify the code to display each slide's title instead of its index. You could also modify it to dump the text directly into Word, perhap applying the H1 style to the slide names.

I may work on those changes later, but this is good enough for me for now.

Download the example to experiment with it and to see additional details.

© 2009-2022 Rocky Mountain Computer Consulting, Inc. All rights reserved.