Search code examples
vbatextboxpowerpointgroup

Grouping text boxes/set of shapes


I have 3 text boxes that are created on a slide via vba. this means that they will all start with the name "TextBox" but the numbers behind the name will be different every time. these are the only text boxes on the slide

I want to use vba to group all text boxes together.

no need to change anything, just group them so they move as a group if needed.


Solution

  • I figured it out

    I knew I was only going to have 3 text boxes at a time so this worked. basically since the text boxes could end in any number, I renamed them to box1, box2, box3. and then grouped the box shapes

    Dim SLD As Slide
    Dim D As Long
    Dim T As Integer
    Set SLD = ActivePresentation.Slides(9)
    
    T = 1
    For D = SLD.Shapes.Count To 1 Step -1
        If SLD.Shapes(D).Type = msoTextBox Then
            SLD.Shapes(D).Name = "Box" & T
            T = T + 1
        End If
    Next
    
     SLD.Shapes.Range(Array("Box1", "Box2", "Box3")).Group