How to extract all text from a PPT presentation

J

John Svendsen

Hi All,

I need to extract all texts from PPT presentations to pre-process for
translations.
I've built a macro, but it does not work - can someone please look at it and
hopefully shed some light on what is wrong?
Thanks a lot! JS
--------------------------
Sub ReadText()
'
Dim sFirst As String
Dim sLast As TextRange
Open "c:\abc.txt" For Output As #1
'Print #1, "test"
Do While Not EOF(1)
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
' MsgBox TextRange.Text
' trying one way...
TextFrame.TextRange.selstart = 0
TextFrame.TextRange.sellength = TextFrame.textlength
TextFrame.TextRange.Copy
sFirst = GetFromClipboard
Print #1, sFirst
' trying another way...
sLast = TextRange.Text
Set sLast = TextFrame.TextRange.Text
sLast = ActiveWindow.Selection.TextRange
Print #1, sLast
End If
Next
Next
Loop
Close #1
End Sub
 
B

Bill Dilworth

Personally, I'd avoid the clipboard. Try this:

===Begin======
Sub TextOut()
Dim sld As Integer
Dim shp As Integer

Open "c:\TextOut.txt" For Output As #1

For sld = 1 To ActivePresentation.Slides.Count
With ActivePresentation.Slides(sld)
For shp = 1 To .Shapes.Count
With .Shapes(shp)
If .HasTextFrame Then
Print #1, .TextFrame.TextRange.Text
End If
End With
Next shp
End With
Next sld

Close #1

End Sub
======End========

Bill Dilworth, Microsoft PPT MVP
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
S

Shyam Pillai

John,

Sub ReadText()
Dim shp As Shape
Dim sld As Slide

Open "c:\abc.txt" For Output As #1
On Error Resume Next
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
Print #1, shp.TextFrame.TextRange
End If
End If
Next
Next
Close #1
End Sub

Regards
Shyam Pillai

http://www.mvps.org/skp
 
J

John Langhans [MSFT]

[CRITICAL UPDATE - Anyone using Office 2003 should install the critical
update as soon as possible. From PowerPoint, choose "Help -> Check for
Updates".]
[TOP ISSUE - Are you having difficulty opening presentations in PPT 2003
that you just created in PPT 2003? -
http://support.microsoft.com/?id=329820]

Hello,

If you (or anyone else reading this message) have suggestions for how to
make this easier to do in PowerPoint (for example, NOT require a macro),
don't forget to send your feedback (in YOUR OWN WORDS, please) to Microsoft
at:

http://register.microsoft.com/mswish/suggestion.asp

It's VERY important that, for EACH wish, you describe in detail, WHY it is
important TO YOU that your product suggestion be implemented. A good wish
submssion includes WHAT scenario, work-flow, or end-result is blocked by
not having a specific feature, HOW MUCH time and effort ($$$) is spent
working around a specific limitation of the current product, etc. Remember
that Microsoft receives THOUSANDS of product suggestions every day and we
read each one but, in any given product development cycle, there are ONLY
sufficient resources to address the ones that are MOST IMPORTANT to our
customers so take the extra time to state your case as CLEARLY and
COMPLETELY as possible so that we can FEEL YOUR PAIN.

IMPORTANT: Each submission should be a single suggestion (not a list of
suggestions).

John Langhans
Microsoft Corporation
Supportability Program Manager
Microsoft Office PowerPoint for Windows
Microsoft Office Picture Manager for Windows

For FAQ's, highlights and top issues, visit the Microsoft PowerPoint
support center at: http://support.microsoft.com/default.aspx?pr=ppt
Search the Microsoft Knowledge Base at:
http://support.microsoft.com/default.aspx?pr=kbhowto

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
B

Bill Dilworth

LOL

Shyam Pillai said:
John,

Sub ReadText()
Dim shp As Shape
Dim sld As Slide

Open "c:\abc.txt" For Output As #1
On Error Resume Next
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
Print #1, shp.TextFrame.TextRange
End If
End If
Next
Next
Close #1
End Sub

Regards
Shyam Pillai

http://www.mvps.org/skp
 
Top