2.Create Bulleted lists and pictures

One of the most commonly required tasks when preparing a presentation are to format a bulleted list and to insert a picture into the slide. The below VBA code creates the bullet list, duplicates it and adds an image from the hard drive to the bottom right of the current slide. The picture below shows the final result.

If you want to learn more about how to insert a VBA code into PowerPoint and how to assign it to a shape, you can read through this blog .

Sub BulletsPointswithPics()
  Dim bullet_text, inner_text, act_pres As Presentation, img As Shape
    Set act_pres = ActivePresentation
    bullet_text = Array("One", "Two", "Three", "Four")
        With act_pres.Slides(1)
            With .Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 400, 200)
                With .TextFrame
                  .WordWrap = msoTrue
                    With .TextRange
                      .Paragraphs(Start:=1, Length:=1).ParagraphFormat.Bullet.Visible = -1
                            For Each inner_text In bullet_text
                              .Text = .Text & inner_text & vbCr
                            Next
                    End With
                End With
            End With
        End With
    sc = act_pres.Slides(1).Shapes.Count
    act_pres.Slides(1).Shapes(sc).TextFrame.TextRange.Font.Size = 30
    act_pres.Slides(1).Shapes(sc).TextFrame.TextRange.ParagraphFormat.Bullet.Style = _
      ppBulletCircleNumWDBlackPlain
    act_pres.Slides(1).Shapes(sc).Copy
    act_pres.Slides(1).Shapes.Paste              ' duplicate the shape
        With act_pres.Slides(1).Shapes(sc + 1)
          .Top = act_pres.Slides(1).Shapes(sc).Top
          .Left = act_pres.Slides(1).Shapes(sc).Left + act_pres.PageSetup.SlideHeight / 3
        End With
    Set img = act_pres.Slides(1).Shapes.AddPicture("E:\Images\Logo.png", _
      msoFalse, msoTrue, 630, 390, 15, 15)      
        With act_pres.PageSetup
          img.Name = "logo"
          img.Width = .SlideWidth / 4
          img.Height = .SlideHeight / 5
        End With
End Sub

Make sure to change the directory location of your image in above code (Replace “E:\Images\Logo.png” with your image location) and make sure to enclose it with double quotes (” “).

Output :

Leave a Reply