I have a PPT template where i need to select the shapes (both headings and body shape) between the black lines. Please note these shapes can change their top, left,height and width. I want to make it so flexible that even if i add any shape(like subtitle or conclusion) between these black lines, still my code will select the above shapes only(both headings and body).
What i have tried:
1)Using name or id, i selected these shapes but that will not fulfill my objective (Objective: to select a shape and create a copy), so creating a copy will still have a same name, which i don't want.
2)I have defined range(top, left, height and width), but this is static. Can i make it dynamic? Below is the code for range selection -
Sub Add_Row_below()
currentslide = ActiveWindow.Selection.SlideRange.SlideIndex
'Selecting Only Shapes within a specified Range
pTop = 78
pLeft = 18
pHeight = 370
pWidth = 686
Count = 0
Dim slideShapes As Shapes
Dim slideShape As Shape
'Get shapes for the slide
Set slideShapes = ActivePresentation.Slides(currentslide).Shapes
'Remove any existing selection
ActiveWindow.Selection.Unselect
'Loop through the shapes
For Each slideShape In slideShapes
'Check if shape is within the specified boundary
If ((slideShape.Top >= pTop And slideShape.Top <= (pTop +pHeight)) _
And (slideShape.Left >= pLeft And slideShape.Left <= (pLeft + pWidth))) Then
'Add the shape to the current selection
slideShape.Select (msoFalse)
Count = Count+ 1
'Shrink text when overflow
slideShape.TextFrame2.AutoSize = msoAutoSizeTextToFitShape
End If
Next slideShape
End Sub
Note:- template screenshot is attached. enter image description here
Adding template created after a button click: enter image description here
Adding template containing possible shapes(subtitles and conclusion) between the two lines: enter image description here