Enhancement to PowerPoint text-exporting macros

  • Thread starter Thread starter Rojo
  • Start date Start date
R

Rojo

Hi Everybody,

Kathy Jacobs was kind enough to direct me to
http://www.pptfaq.com/FAQ00274.htm, which is a FAQ page containing three
macros that export slide text to a text document. I used the third macro
successfully, and it has the potential of saving me an enormous amount of
time. I am an editor, and when I edit a Word document with PowerPoint
slides, I have to make comments in the Word document. It is extraordinarily
time-consuming to have to write things like "In the 3rd bullet point in the
bottom part of the slide, change "only has" to "has only". I can use this
macro to paste the text into the comments pane, or I can paste it into
another Word document and edit using track changes, if the publisher will
let me. However, there is one enhancement that would make this even better:
listing the sequential slide number at the beginning of the slide text. You
know how PowerPoint automatically numbers the slides? These are the numbers
that I could use to easily find the right slide when searching through the
text document.

If one of you tweak the code to provide this enhancement, you'd have my
eternal gratitude.

Joel
 
You might try this (I didn't test it, so I don't know if it will work).
After the line:

For Each oSld In oSlides 'Loop thru each slide

Stick the following line of code:

Print #iFile, "Slide #:" & vbTab & oSld.SlideIndex

Although, you might want to use SlideNumber, instead of SlideIndex.
According to the VBA help:

The SlideNumber property of a Slide object is the actual number that
appears in the lower-right corner of the slide when you display slide
numbers. This number is determined by the number of the slide within the
presentation (the SlideIndex property value) and the starting slide
number for the presentation (the FirstSlideNumber property value). The
slide number is always equal to the starting slide number + the slide
index number – 1.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Try adapting the code like this:

If oShp.Type = msoPlaceholder Then
Select Case oShp.PlaceholderFormat.Type
Case Is = ppPlaceholderTitle, ppPlaceholderCenterTitle
Print #iFile, "slide no. "; oSld.SlideIndex& & " / " &
"Title:" & vbTab & oShp.TextFrame.TextRange
Case Is = ppPlaceholderBody
Print #iFile, "slide no. "; oSld.SlideIndex & "Body:" &
vbTab & oShp.TextFrame.TextRange
Case Is = ppPlaceholderSubtitle
Print #iFile, "slide no. "; oSld.SlideIndex &
"SubTitle:" & vbTab & oShp.TextFrame.TextRange
Case Else
Print #iFile, "slide no. "; oSld.SlideIndex & "Other
Placeholder:" & vbTab & oShp.TextFrame.TextRange
End Select
--

Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist
http://www.technologytrish.co.uk/ppttipshome.html
 
I got a syntax error. I really have no idea of how to do this. I was hoping
that someone would add the code to the existing macro.

Joel
 
I just tested it out, and it worked perfectly for me. Try again. Are you
sure you put just the one line I included below

Print #iFile, "Slide #:" & vbTab & oSld.SlideIndex

as its own separate line underneath the line starting with For Each oSld
(this should be, I think, the 29th line of the code, counting blank
lines)?

I hadn't tested it when I posted the first time, but now I have tested
it, and I think it does just what you want.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Does it get indented or not?

David M. Marcovitz said:
I just tested it out, and it worked perfectly for me. Try again. Are you
sure you put just the one line I included below

Print #iFile, "Slide #:" & vbTab & oSld.SlideIndex

as its own separate line underneath the line starting with For Each oSld
(this should be, I think, the 29th line of the code, counting blank
lines)?

I hadn't tested it when I posted the first time, but now I have tested
it, and I think it does just what you want.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Whole thing!

Sub ExportText()

Dim oPres As Presentation
Dim oSlides As Slides
Dim oSld As Slide
Dim oShp As Shape
Dim iFile As Integer
iFile = FreeFile
Dim PathSep As String
Dim FileNum As Integer
Dim sTempString As String

#If Mac Then
PathSep = ":"
#Else
PathSep = "\"
#End If

Set oPres = ActivePresentation
Set oSlides = oPres.Slides

FileNum = FreeFile

Open oPres.Path & PathSep & "AllText.TXT" For Output As FileNum

For Each oSld In oSlides
For Each oShp In oSld.Shapes


If oShp.HasTextFrame And oShp.TextFrame.HasText Then
If oShp.Type = msoPlaceholder Then
Select Case oShp.PlaceholderFormat.Type
Case Is = ppPlaceholderTitle, ppPlaceholderCenterTitle
Print #iFile, "slide no. "; oSld.SlideIndex& & " / " & _
"Title:" & vbTab & oShp.TextFrame.TextRange
Case Is = ppPlaceholderBody
Print #iFile, "slide no. "; oSld.SlideIndex& & " / " _
& "Body:" & vbTab & oShp.TextFrame.TextRange
Case Is = ppPlaceholderSubtitle
Print #iFile, "slide no. "; oSld.SlideIndex& & " / " _
& "SubTitle:" & vbTab & oShp.TextFrame.TextRange
Case Else
Print #iFile, "slide no. "; oSld.SlideIndex& & " / " _
& "Other Placeholder:" & vbTab & oShp.TextFrame.TextRange
End Select
Else
Print #iFile, vbTab & oShp.TextFrame.TextRange
End If
Else
If oShp.Type = msoGroup Then
sTempString = TextFromGroupShape(oShp)
If Len(sTempString) > 0 Then
Print #iFile, sTempString
End If
End If
End If

Next oShp
Next oSld


Close #iFile

End Sub

Function TextFromGroupShape(oSh As Shape) As String


Dim oGpSh As Shape
Dim sTempText As String

If oSh.Type = msoGroup Then
For Each oGpSh In oSh.GroupItems
With oGpSh
If .Type = msoGroup Then
sTempText = sTempText & TextFromGroupShape(oGpSh)
Else
If .HasTextFrame Then
If .TextFrame.HasText Then
sTempText = sTempText & "(Gp:) " & .TextFrame.TextRange.Text & vbCrLf
End If
End If
End If
End With
Next
End If

TextFromGroupShape = sTempText

NormalExit:
Exit Function

Errorhandler:
Resume Next

End Function

--

Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist
http://www.technologytrish.co.uk/ppttipshome.html
 
I take it back. It worked once for one presentation, but with every other,
all I get is a compile error/syntax error.

Joel
 
Hi,

I've modified the code to include the slide *number*.
This is the number that'll appear on the slide if slide numbering is enabled.
Usually it starts at 1 and goes from there, but if the user's changed the
starting number in Page Setup, this will reflect that.

Export Text to a text file (Mac or PC)
http://www.pptfaq.com/FAQ00274.htm
 
If it worked for one presentation, that means that the problem is not
with the code (at least it means that for a compile error; there are some
kinds of errors that could manifest themselves in one presentation and
not others, but not a compile error). It must be with how you are copying
and pasting the code into the other presenations. You'll have to try
copying and pasting the code again. Be sure you delete all the other (not
working) code before pasting again.

If this is really going to save you as much time as you think, I'll bet
you could hire someone (Steve? Shyam? Bill? others?) to turn this into an
add-in for you. Once you load the add-in on your computer, you should be
able to run it with any presentation without copying and pasting code. I
wouldn't think it would even be too expensive (I don't do this so I can't
quote you a rate) because the code is already written. The hard part will
be the human side (explaining to you how to install it).

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
David M. said:
If it worked for one presentation, that means that the problem is not
with the code (at least it means that for a compile error; there are some
kinds of errors that could manifest themselves in one presentation and
not others, but not a compile error). It must be with how you are copying
and pasting the code into the other presenations. You'll have to try
copying and pasting the code again. Be sure you delete all the other (not
working) code before pasting again.

If this is really going to save you as much time as you think, I'll bet
you could hire someone (Steve? Shyam? Bill? others?) to turn this into an
add-in for you. Once you load the add-in on your computer, you should be
able to run it with any presentation without copying and pasting code. I
wouldn't think it would even be too expensive (I don't do this so I can't
quote you a rate) because the code is already written. The hard part will
be the human side (explaining to you how to install it).

Good point. In fact, elsewhere on the FAQ site, it explains how to create your
own addin.
 
Well I certainly want to thank everybody for their help. I may very well go
for the add-in. It seems to me that in Word, a macro acts as an add-in. Does
it not work that way in PowerPoint because PowerPoint doesn't use universal
templates like the Normal template in Word?

Joel
 
Well I certainly want to thank everybody for their help. I may very well go
for the add-in. It seems to me that in Word, a macro acts as an add-in.

The Office apps all host macros in different ways. You can get macros to run
automatically at startup and/or when you open a template in Word. PowerPoint
allows neither of those things (and spreads fewer viruses as a result, to look
 
Back
Top