Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Dec 2000
    Location
    Helena, MT, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PowerPoint 97: How to ref text box collection

    I want to write a macro that loops through the entire list of text boxes within a presentation, and copies the text within them to the Windows clipboard (or some other location from which they can be copied) as a single clip. What is the correct syntax for referring to the collection of text boxes?

    From the help file, it looks something like
    <hr><pre>Set myShapes = ActivePresentation.Slides(1).Shapes
    For Each s In myShapes
    If s.HasTextFrame Then
    .. process rest of commands here ..
    End If
    Next</pre>

    <hr>
    Does that look right? Anyone offer any improvements? Using the ActivePresentation.Slides(1).Shapes construction, it looks like it will only capture info from text boxes on the first slide, not subsequent ones.

    What's the best way to make the info available after the macro has run, so that it is either already in the Windows clipboard, or available through some kind of dialog box to copy from manually?

  2. #2
    New Lounger
    Join Date
    Dec 2000
    Location
    Helena, MT, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: PowerPoint 97: How to ref text box collection

    Partial answer - from Help files again. This example extracts text from all shapes on myDocument that contain text frames, and then it stores the names of these shapes and the text they contain in an array.
    <hr><pre>Dim shpTextArray() As Variant
    Dim numShapes, numAutoShapes, i As Long

    Set myDocument = ActivePresentation.Slides(1)
    With myDocument.Shapes
    numShapes = .Count
    If numShapes > 1 Then
    numTextShapes = 0
    ReDim autoShpArray(1 To 2, 1 To numShapes)
    For i = 1 To numShapes
    If .Item(i).HasTextFrame Then
    numTextShapes = numTextShapes + 1
    shpTextArray(numTextShapes, 1) = .Item(i).Name
    shpTextArray(numTextShapes, 2) = .Item(i).TextFrame.TextRange.Text

    End If
    Next
    ReDim Preserve shpTextArray(1 To 2, 1 To numAutoShapes)
    End If
    End With</pre>

    <hr>

  3. #3
    New Lounger
    Join Date
    Dec 2000
    Location
    Helena, MT, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PP97: How to ref text boxes complication

    I think I got the first bit figured out, but now there's an extra problem. Most (but not all) of the text boxes are grouped together with other (graphical) objects. It looks like the TextFrame.TextRange can't be read when it is part of a grouped object? Is that correct?

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: PP97: How to ref text boxes complication

    You need to ungroup the textboxes in order to get at the individual text frames (and then regroup them).

    There's some code that does this in Word here - this will probably work in PPT too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •