VBA PowerPoint - Copy shape or group

425 Views Asked by At

I am trying to use VBA in PowerPoint to copy 2 shapes and a group of shapes called SP_MP, SP_TEST and the group called SP_MP_START from the active slide in the same slide, in the following location 83.52, 41.62. Issue is I don't know how to reference to the shapes and group to copy them and what commands to use.

Thank you in advance, Stefan.

1

There are 1 best solutions below

1
On
    Private Sub CommandButton1_Click()

Dim Sld As Slide
Dim Shp As Shape

'ERROR HANDLING
    If ActivePresentation.Slides.Count = 0 Then
        MsgBox "You do not have any slides in your PowerPoint project."
        Exit Sub
    End If

Set Sld = Application.ActiveWindow.View.Slide

'Create shape with Specified Dimensions and Slide Position
    Set Shp = Sld.Shapes.AddShape(Type:=msoShapeFlowchartPredefinedProcess, _
        Left:=50, Top:=100, Width:=83.52, Height:=41.62)

'FORMAT SHAPE
    'Shape Name
        Shp.Name = "My Header"

    'No Shape Border
        Shp.Line.Visible = msoTrue

    'Shape Fill Color
        Shp.Fill.ForeColor.RGB = RGB(255, 255, 255)

    'Shape Text Color
        Shp.TextFrame.TextRange.Font.Color.RGB = RGB(0, 0, 0)

    'Text inside Shape
        Shp.TextFrame.TextRange.Characters.Text = TextBox1

    'Center Align Text
        Shp.TextFrame.TextRange.Paragraphs.ParagraphFormat.Alignment = ppAlignCenter

    'Vertically Align Text to Middle
        Shp.TextFrame2.VerticalAnchor = msoAnchorMiddle

    'Adjust Font Size
        Shp.TextFrame2.TextRange.Font.Size = 8

    'Adjust Font Style
        Shp.TextFrame2.TextRange.Font.Name = "Verdana (Body)"

Unload UserForm4

End Sub