Supercharge your PowerPoint productivity with

Supercharge your PPT Productivity with PPTools - Click here to learn more.

Tell me about PPTools

Importing notes text from a text file


PPTools
Shape Styles brings the power of styles to PowerPoint. Apply complex formatting with a single click
Merge Excel, CSV or tab-delimited data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more
FixLinks prevents broken links when you distribute PowerPoint presentations
Optimizer saves disk space and bandwidth, shrinks your PowerPoint presentations to the right size for email, screenshow or printing
PPT2HTML gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements
Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF
Image Export converts PowerPoint slides to JPG, PNG, GIF, WMF and more

Problem

You have your notes text in an external text file and want to import it into the notes pages of your presentation.

Solution

Create a text (notepad) file that looks like this:

=== Slide 1
Here is the notes text for slide 1
=== Slide 2
Here is the notes text for slide 2
===
The "===" as the first three characters on the line separates each slide's notes text.
Any characters after the first three "===" are ignored, so you can use them
for comments or to identify the slides. Or just use "===" if you like.
===
And so on
=== 
And so forth.

Open the presentation you want to import text into and run this macro.

It will look for a text file (ie a notepad file) of the same base name as the current presentation and apply each slide's worth of notes to the corresponding slide.

If there are more notes than slides to accept them, it throws excess notes away.

Sub TxtToNotes()
' Run this ONLY on a COPY of your real presentation
'
' Pulls text from a notepad TXT file into current
' presentation's Notes text
'
' Each slide's worth of notes is delineated by ===
'
' Notes text file must be in same folder as PPT
'  and must have the same base name
'  ex:  Blah.ppt looks for Blah.txt
'
' Method of locating notes text placeholder isn't 100%
' reliable; may fail with some presentations

    Dim sNotesFileName As String
    Dim iNotesFileNum As Integer
    Dim sCurrentFolder As String
    Dim lSlideNumber As Long
    Dim sBuf As String
    Dim sNotes As String

    sCurrentFolder = ActivePresentation.Path & "\"
    ' get everything to the left of "." in current filename
    sNotesFileName = Mid$(ActivePresentation.Name, _
        1, InStr(ActivePresentation.Name, ".") - 1)
    ' and add a .TXT extension
    sNotesFileName = sNotesFileName & ".TXT"

    ' is it there? quit if not
    If Len(Dir$(sCurrentFolder & sNotesFileName)) = 0 Then
        MsgBox sCurrentFolder & sNotesFileName & " is missing"
        Exit Sub
    End If

    ' open the file and go to work
    iNotesFileNum = FreeFile()
    Open sCurrentFolder & sNotesFileName For Input As iNotesFileNum

    lSlideNumber = 1

    ' test for leading ===
    Line Input #iNotesFileNum, sBuf
    If Left$(sBuf, 3) = "===" Then
        ' ignore it
    Else
        sNotes = sBuf
    End If

    While Not EOF(iNotesFileNum)
        Line Input #iNotesFileNum, sBuf
        ' is it a ===? if so, write current notes out to slide
        ' and start over
        If Left$(sBuf, 3) = "===" Then
            If ActivePresentation.Slides.Count >= lSlideNumber Then
                 With ActivePresentation.Slides(lSlideNumber).NotesPage
                     ' this is a crude and unreliable way of
                     ' locating the notes text placeholder
                     With .Shapes(2)
                         .TextFrame.TextRange.Text = sNotes
                     End With
                 End With
                lSlideNumber = lSlideNumber + 1
                ' reset the current notes for the next round
                sNotes = ""
            End If
        Else
            sNotes = sNotes & sBuf
        End If
    Wend

    ' if we're at the end of the file and there's still text
    ' in the buffer, write it to the next slide
    If ActivePresentation.Slides.Count >= lSlideNumber Then
        With ActivePresentation.Slides(lSlideNumber).NotesPage
            ' this is a crude and unreliable way of
            ' locating the notes text placeholder
            With .Shapes(2)
                .TextFrame.TextRange.Text = sNotes
            End With
        End With
    End If

    ' close the file
    Close iNotesFileNum

End Sub

See How do I use VBA code in PowerPoint? to learn how to use this example code.


Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2008 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.

Español    Deutsch    Français    Português    Italiano    Nederlands    Greek    Japanese    Korean    Chinese



Supercharge your PPT Productivity with PPTools


content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Importing notes text from a text file
http://www.pptfaq.com/FAQ00937.htm
Last update 29 April, 2008