March 9, 2009
How to print notes of a powerpoint file only?
If you only want to print notes, you can follow the instruction of office online help here.
But if the notes is too long, you can not print it in one page, you have to sort of “hack”.
Here is a solution of exporting the notes from a powerpoint file to a text file. Then you can print it as you wish.
Option Explicit
Sub ExportNotesText()
Dim oSlides As Slides
Dim oSl As Slide
Dim oSh As Shape
Dim strNotesText As String
Dim strFileName As String
Dim intFileNum As Integer
Dim lngReturn As Long
Dim count As Integer
' Get a filename to store the collected text
strFileName = InputBox("Enter the full path and name of file to extract notes text to", "Output file?")
' did user cancel?
If strFileName = "" Then
Exit Sub
End If
' is the path valid? crude but effective test: try to create the file.
intFileNum = FreeFile()
On Error Resume Next
Open strFileName For Output As intFileNum
If Err.Number <> 0 Then ' we have a problem
MsgBox "Couldn't create the file: " & strFileName & vbCrLf _
& "Please try again."
Exit Sub
End If
Close #intFileNum ' temporarily
' Get the notes text
Set oSlides = ActivePresentation.Slides
count = 0
For Each oSl In oSlides
count = count + 1
strNotesText = strNotesText & "======================================" & vbCrLf
strNotesText = strNotesText & "#" & count & ":" & SlideTitle(oSl) & vbCrLf
strNotesText = strNotesText & NotesText(oSl) & vbCrLf
Next oSl
' now write the text to file
Open strFileName For Output As intFileNum
Print #intFileNum, strNotesText
Close #intFileNum
' show what we've done
lngReturn = Shell("NOTEPAD.EXE " & strFileName, vbNormalFocus)
End Sub
Function SlideTitle(oSl As Slide) As String
Dim oSh As Shape
For Each oSh In oSl.Shapes
If oSh.Type = msoPlaceholder Then
If oSh.PlaceholderFormat.Type = ppPlaceholderTitle _
Or oSh.PlaceholderFormat.Type = ppPlaceholderCenterTitle Then
If Len(oSh.TextFrame.TextRange.Text) > 0 Then
SlideTitle = oSh.TextFrame.TextRange.Text
Else
SlideTitle = "Slide " & CStr(oSl.SlideIndex)
End If
Exit Function
End If
End If
Next
End Function
Function NotesText(oSl As Slide) As String
Dim oSh As Shape
For Each oSh In oSl.NotesPage.Shapes
If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then
If oSh.HasTextFrame Then
If oSh.TextFrame.HasText Then
NotesText = oSh.TextFrame.TextRange.Text
End If
End If
End If
Next oSh
End Function
How to use the code?
- In Powerpoint 2007, firstly open the develop tab from the “Start” button at left-top, then Powerpoint Options –> Show Developer tab in the Ribbon.
- Close the Option, Main View->Developer-> Visual Basic
- In the editor, paste all the code above.
- Go to the Line inside Sub ExportNotesText(), click the run button.
- Type a file name, you can use C:\ or D:\ to make the file easier to be found.
- It may open the file automatically. You can print it now, or use Word to re-format it and print.
Code from:
http://pptfaq.com/FAQ00481.htm
with a small modification of adding slides number before the each slides title.
Comments(0)