简体   繁体   中英

VBA PowerPoint - Copy shape or group

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.

    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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM