Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting text out of Powerpoint 1

Status
Not open for further replies.

OsakaWebbie

Programmer
Feb 11, 2003
628
JP
Is it possible in Powerpoint 2003 to copy the contents of a series of slides to the clipboard in such a way that the text can be used in other programs? (If it is relevent, the usual destination will be MS Word.) When I select multiple slides in the outline and copy/paste, I only get the titles (not the body text of the slides), even if the outline pane was expanded to see the text when I copied. I know I can copy the text from an individual slide (in the slide window of Normal view), but it's cumbersome to copy/paste the title and then the body over and over for many slides - this will be a regular operation done every week. Thanks in advance for any suggestions.
 
Thank you for replying, Claudius. But after looking at the link you pointed me to for copying text, I don't think you understand what I want to do. Of course I can copy text from a given text box on a given slide, but as I said in my first post, it would take a long time to use that method to copy, for example, the title and body contents of 20 slides (it would take 40 copy/paste iterations). I want to copy all the title and body content of multiple consecutive slides in one step. (In case anyone is wondering, there are no extra text boxes or graphics in these slides, only text entered into the title and body placeholders.) I can do it with titles, by selecting a series of slides in the outline pane and copying, but it won't give me the body content. As for your second comment, I don't want the whole file, just selected series's of slides. Any other thoughts, someone?
 
I don't know if you found your solution, but I used this to get the text boxes from a PPt presentation and put them in Excel. It gets all the textboxes, but after they are in excel, you can pick the ones you want.

You need to reference the PowerPoint object library under Tools/Preferences.

Hope it helps.

Option Explicit

Private Sub CommandButton1_Click()
Dim oPPa As PowerPoint.Application
Dim oPPp As PowerPoint.Presentation
Dim oPPsl As PowerPoint.Slide
Dim i, j As Integer

Set oPPa = New PowerPoint.Application
oPPa.Visible = msoTrue
Set oPPp = oPPa.Presentations.Open("C:\Temp\AmericanGeneral R3 Overview Presentation_a.ppt")

j = 3

For Each oPPsl In oPPp.Slides
Range("A" & j) = "Title for slide " & oPPsl.SlideNumber
If Not oPPsl.Master.Name = "TitleMaster" Then
If oPPsl.Shapes.HasTitle Then
Range("B" & j) = oPPsl.Shapes.Title.TextFrame.TextRange.Text
End If
End If
j = j + 1
For i = 1 To oPPsl.Shapes.Count
Select Case True
Case oPPsl.Shapes(i).Type = msoTextBox
Range("A" & j) = "Shape Name - " & oPPsl.Shapes(i).Name
Range("B" & j) = oPPsl.Shapes(i).TextFrame.TextRange.Text
j = j + 1
Case oPPsl.Shapes(i).AutoShapeType = msoShapeRectangle
Range("A" & j) = "Shape Name - " & oPPsl.Shapes(i).Name
Range("B" & j) = oPPsl.Shapes(i).TextFrame.TextRange.Text
j = j + 1
End Select
Next i

Next oPPsl

oPPp.Close

Set oPPp = Nothing
oPPa.Quit
Set oPPa = Nothing

Columns("A:B").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.ShrinkToFit = False
.MergeCells = False
End With

End Sub


Rene'
 
Wow, thanks for the script, rdeleon, and for the link, TAJ. It seems that everyone except me wants to get ALL the slides from a given presentation, rather than a selected series of them. I didn't realize how hard this was going to be! [surprise] The script you posted is no doubt VBA for Excel, but if I get time, perhaps I can take the ideas in it and learn enough VBA for Powerpoint (I've only coded for Access before, but I'm sure I can learn) to write something similar that will take the selected slides and write them to Word, or write it in VBA for Word if from there I can detect what is selected in an open Powerpoint file. But it'll take time, something that's a very precious commodity for me right now... [ponder]
 
This might be closer to what you are looking for.



Option Explicit

Sub XportToWord()

Dim oPPsl As PowerPoint.Slide
Dim i, j As Integer
Dim sIDs As String

sIDs = ":"

For Each oPPsl In ActiveWindow.Selection.SlideRange
sIDs = sIDs & CStr(oPPsl.SlideID) & ":"
Next oPPsl

Open ActivePresentation.Path & "\" & "PPText.doc" For Output As #1

With ActivePresentation
For i = 1 To .Slides.Count
If InStr(1, sIDs, ":" & CStr(.Slides(i).SlideID) & ":") <> 0 Then
If Not .Slides(i).Master.Name = "TitleMaster" Then
If .Slides(i).Shapes.HasTitle Then
Print #1, "Title for slide " & .Slides(i).SlideID & " - " & _
.Slides(i).Shapes.Title.TextFrame.TextRange.Text
End If
End If
For j = 1 To .Slides(i).Shapes.Count
Select Case True
Case .Slides(i).Shapes(j).Type = msoTextBox
Print #1, "Shape Name - " & .Slides(i).Shapes(j).Name & " - " & _
.Slides(i).Shapes(j).TextFrame.TextRange.Text
Case .Slides(i).Shapes(j).AutoShapeType = msoShapeRectangle
Print #1, "Shape Name - " & .Slides(i).Shapes(j).Name & " - " & _
.Slides(i).Shapes(j).TextFrame.TextRange.Text
End Select
Next j
Print #1,
End If
Next i
End With

Close #1


End Sub


Past the code in the VBA Editor
Select slides from slide show view
Run the macro.

The code will produce a text file "PPText.doc" in the path of the active presentation.

Hope this helps.

Rene'
 
Wow, that looks like you wrote that just for me! I am currently traveling, so I can't try it for a couple weeks, but it will be top on my list when I get back. Even before I test it, I'll give you a star now, just for writing it (or finding it wherever you did). The TekTips community is awesome!
 
Well, I'm home now, and not only was I able to run rdeleon's code (thanks again!), but while modifying a little for my needs I even discovered ways to tighten up the code a little (after learning how the original code worked, it was easier to know what to look up in the documentation; starting from scratch would have been hard). In the original I was getting two copies of each slide's title - I fixed that, and redid the formatting of the output for my needs, and in the process also discovered that if you use SlideIndex instead of SlideID you can loop through the Selection.SlideRange directly rather than making a list and then checking all slides against it. For those who are curious, my updated code is below.

My last snag is that what I really want is to put the stuff into the clipboard rather than making a file, but I haven't figured out yet how to get the contents of my string variable (after collecting all the text) into the clipboard, as all clipboard commands I can find are methods of objects, and suggestions I found by web searches didn't work. If anyone here has any ideas that would be great, but I know it's getting a bit off-topic, so I'll also ask on the VBA forum.

Code:
Sub SlideExport()
    
    Dim oPPsl As PowerPoint.Slide
    Dim j As Integer
    
    Open ActivePresentation.Path & "\" & "PPText.txt" For Output As #1
    
    With ActivePresentation
        For Each oPPsl In ActiveWindow.Selection.SlideRange
            With .Slides(oPPsl.SlideIndex)
                If (Not .Master.Name = "TitleMaster") _
                And (.Shapes.HasTitle) Then
                    Print #1, "Title: " & _
                    .Shapes.Title.TextFrame.TextRange.Text
                    Print #1,
                End If
                For j = 1 To .Shapes.Count
                    If ((.Shapes(j).Type = msoTextBox) _
                    Or (.Shapes(j).AutoShapeType = msoShapeRectangle)) _
                    And Not (.Shapes(j).TextFrame.TextRange.Text = _
                    .Shapes.Title.TextFrame.TextRange.Text) Then
                        Print #1, .Shapes(j).TextFrame.TextRange.Text
                        Print #1,
                    End If
                Next j
            End With
        Next oPPsl
    End With
    
    Close #1

End Sub
 
Never mind about the clipboard issue - with a little more research I got it to work (I needed to reference the Forms object library in order to use the DataObject type). Once again, Tek-Tips came through - I found my answer by searching in the VBA forum and looking at problems others have had.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top