I have a group of groups of shapes, the relevant ones of which are pairs made of a shape and a text box (the whole drawing is imported as SVG image and ungrouped to make it editable). I would like, for each of the pairs, the shapes to be renamed after what's written in the text boxes, but I cannot find a way to access such shapes. I get the error objects does not support property or method
at "Target" and I have tried several ways to name it (oSh(G).GroupItems(i)
among others) but non is the correct way, could someone please help me?
Sub GiveNamesToShapes()
Dim oSlide As slide
Dim oSh As Shape
Dim i As Integer
Dim Source As String
Dim Target As Shape
Dim Group As Shape
Dim G As Integer
For Each oSh In ActivePresentation.Slides(1).Shapes
For G = 1 To ActivePresentation.Slides(1).Shapes.Count
If ActivePresentation.Slides(1).Shapes(G).Type = msoGroup Then
For i = 1 To oSh.GroupItems.Count
If oSh.GroupItems(i).TextFrame2.HasText = True Then
Source = oSh.GroupItems(i).TextFrame2.TextRange
ElseIf oSh.GroupItems(i).TextFrame2.HasText = False Then
With ActivePresentation.Slides(1).Shapes.Range.GroupItems
Target = oSh.GroupItems(i) ''here the error
End With
End If
With oSh.GroupItems(i) = Target
Set .Name = Source
End With
Next
End If
Next
Next
End Sub