/ Published in: Visual Basic
What It Does Extracts the words out of a selected text shape in Powerpoint, and then creates separate shapes for them.
To use:
- Create your Text shape. Type your text. Format it, color it, etc.
- Select the text shape.
- Run macro.
Expand |
Embed | Plain Text
Sub SplitText() Dim sentence() As String Set mydoc = ActivePresentation.Slides(ActiveWindow.Selection.SlideRange.Name) curshape = ActiveWindow.Selection.ShapeRange.Name twords = Split(ActiveWindow.Selection.TextRange.Text, " ") c = mydoc.Shapes.Count xpos = mydoc.Shapes(curshape).Left ypos = mydoc.Shapes(curshape).Top + mydoc.Shapes(curshape).Height + 10 ReDim sentence(0 To UBound(twords)) For i = 0 To UBound(twords) Set newtxt = mydoc.Shapes.AddTextbox(msoShapeRectangle, xpos, ypos, Len(twords(i)), 1) mydoc.Shapes(curshape).PickUp With newtxt .Apply .Name = "Word_" & c & "-" & (i + 1) With .TextFrame .AutoSize = ppAutoSizeShapeToFitText .WordWrap = msoFalse .TextRange.Text = twords(i) & " " .MarginLeft = 0 .MarginRight = 0 .TextRange.ParagraphFormat.Bullet.Visible = False End With End With 'if text goes out of bounds, move to next line & flush left If (newtxt.Left + newtxt.Width >= ActivePresentation.SlideMaster.Width) Then ypos = newtxt.Top + newtxt.Height xpos = mydoc.Shapes(curshape).Left With newtxt .Top = ypos .Left = xpos End With End If 'computes for xpos for next shape xpos = newtxt.Left + newtxt.Width 'adds to array; for grouping sentence(i) = newtxt.Name Next mydoc.Shapes.Range(sentence).Group End Sub
You need to login to post a comment.
