Supercharge your PowerPoint productivity with
|
PPTools |
ProblemYou have your notes text in an external text file and want to import it into the notes pages of your presentation. SolutionCreate 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. Español Deutsch Français Português Italiano Nederlands Greek Japanese Korean Chinese |
Supercharge your PPT Productivity with PPTools
|
content authoring & site maintenance by |
Importing notes text from a text file
http://www.pptfaq.com/FAQ00937.htm
Last update 29 April, 2008