VBA: Selectively Deleting Notes in a PowerPoint PPT

  • Thread starter Thread starter Greg Dunn
  • Start date Start date
G

Greg Dunn

In my PPT slide decks, I want to have both instructor-only notes, and notes
intended for students. Before distributing, I will need to delete the
instructor-only notes, but leave the others.

Therefore I need a macro to delete a *tagged section* of the notes; e.g., if
the material below (between the dashed lines) were a note for a particular
slide, I would want to remove everything between the "/*" and "*/" tags,
including the tags.

-------------------------------------------------------------------------------------
/* Be sure to not to run this code during the demonstration: it will
reformat your hard disk!
*/

The above code, students, is an example of a program you should never write.
--------------------------------------------------------------------------------------

I've found a couple of macros to delete the notes, period, which I've
included below. If someone can show me how to enhance one of these (or do
something else) to delete only the tagged regions, I would greatly
appreciate it.

Thanks,
Greg Dunn


Delete All Notes: Solution #1 (from Bill Dilworth, 2005-06-23)

Sub BlitzTheNotesText()

Dim oSl As Slide

Dim oSh as Shape

For Each oSl In ActivePresentation.Slides

' Check each shape on the slide's notes page

For Each oSh in oSl.NotesPage.Shapes

' Is the shape a body text placeholder?

' If so, delete it.

If oSh.PlaceHolderFormat.Type = ppPlaceholderBody Then

oSh.Delete

End if

Next oSh

Next oSl

End Sub



Delete All Notes: Solution #2 (from Joshua Seigler, 2/18/2005 )

Dim objSlide As Slide

Dim objShape As Shape



For Each objSlide In ActivePresentation.Slides

For Each objShape In objSlide.NotesPage.Shapes

If objShape.TextFrame.HasText Then

objShape.TextFrame.TextRange = ""

End If

Next

Next
 
Try this .....


Sub BlitzSomeOfTheNotesText()

Dim oSl As Slide
Dim oSh As Shape
Dim iBegin As Integer
Dim iEnd As Integer

For Each oSl In ActivePresentation.Slides

' Check each shape on the slide's notes page
For Each oSh In oSl.NotesPage.Shapes

' Is the shape a body text placeholder?
' If so, delete it.
If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then

iBegin = InStr(1, oSh.TextFrame _
.TextRange.Text, "/*", vbTextCompare)
iEnd = InStr(iBegin + 1, oSh.TextFrame _
.TextRange.Text, "*/", vbTextCompare)
If (iBegin > 0) And (iEnd > iBegin) Then
oSh.TextFrame.TextRange.Characters _
(iBegin, (iEnd - iBegin) + 2).Delete
End If

End If
Next oSh
Next oSl
End Sub



--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
Hi, Bill. Thanks again!

It has subsequently occurred to me that, as I have about 50 separate slide
decks that will need to be processed with this macro, a programmatic loop
operating outside the individual files would be very helpful indeed. I used
to do such things using Access as the control program; now I'm doing .NET so
I suppose VSTO is where I'd be likely to look.

But...if you have a better (or simpler) idea, I'd love to hear it.

Greg Dunn
 
Hi, Bill. Thanks again!

It has subsequently occurred to me that, as I have about 50 separate slide
decks that will need to be processed with this macro, a programmatic loop
operating outside the individual files would be very helpful indeed. I used
to do such things using Access as the control program; now I'm doing .NET so
I suppose VSTO is where I'd be likely to look.

I suppose you could do that, but you could also do it all from within PPT.

Do something to every file in a folder
http://www.rdpslides.com/pptfaq/FAQ00536.htm

The code itself should be in a separate PPT file that's NOT in the folder you intend to
process.
 
Thank you, Steve. That's great! I may not get a chance to try it out for a
day or two, but it looks like it's just about what I need.

Do you (or does anyone) know the VBA function to get the list of
subdirectories in a given directory? My slide decks are in a directory
structure like the following, so I need to do some recursion:

Instructional Units
---Topic 1
------ Slides
---------Topic1.ppt
------ Docs
------ Code

---Topic 2
------ Slides
---------Topic2.ppt
------ Docs
------ Code


Thanks again,

Greg Dunn
 
Interesting one.
I'd probably not use the Notes textbox that comes with the Notes page.
Or I'd use that only for the Teacher or Student Notes. You can add
another regular text box which has a different .Type number and can
tag that with a PPT tag (see VBA Help on that). Then iterate through
all shapes on the Notes pages and delete the textboxes with the
Teacher tags.

Brian Reilly, MVP
 
Do you (or does anyone) know the VBA function to get the list of
subdirectories in a given directory? My slide decks are in a directory
structure like the following, so I need to do some recursion:

Whisper this in Google's ear:

vb recurse subdirectory
 
I see that PPTools has a tool to do that - TagErase
(http://www.rdpslides.com/pptfaq/FAQ00624.htm) -- but there's no visible
indicator of what shapes are so tagged, so it seems like things could get
confused. No doubt a macro could be written to provide same, but...

the more I think about it, a preferable solution would be something external
to PowerPoint itself, like a Sticky Notes program, so that private
annotations would never accompany the powerpoint file unless one went to
some special trouble to see that they did. That would prevent accidents
involving instructor notes that were supposed to get deleted, but didn't.
I'll ask about that in a separate thread.

In any case, thank you for the suggestion!

Greg Dunn
 
Back
Top