VBA Code


Insert a picture onto a slide

Dim objSlide As PowerPoint.Slide 
Dim objPicture As PowerPoint.Picture

objSlide =
objPicture = objSlide.Shapes.AddPicture(FileName:="C:\Temp\Picture.bmp", _
                                        LinkToFile:=msoFalse, _
                                        SaveWithDocument:=msoTrue, _
                                        Left:=0, _
                                        Top:=0, _
                                        Width:=100, _
                                        Height:=100
objPicture.ScaleHeight = 1
objPicture.ScaleWidth = 1


Getting pictures into PowerPoint slides

Import all the bmp files from a folder.

Public Sub GetPictures 
   Dim sMyPhotos As String
   Dim sMyPath As String

   sMyPath = "C:\Photos\"
   sMyPictures = Dir(sMyPath + "*.bmp")

   Call PlacePicture(sMyPath, sMyPhotos)

   Do Until Len(sMyPhotos) = 0
      sMyPhotos = Dir()
      If Len(sMyPhotos) > 0 Then
         ActiveWindow.View.GoToSlide Index:=ActivePresentation.Slides.Add(Index:=1, _
                                                                          Layout:=ppLayoutBlank).SlideIndex

         Call PlacePicture(sMyPath, sMyPhotos)
      End If
   Loop

End Sub


Public Sub PlacePicture(ByVal sMyPath As String, _ 
                        ByVal sMyPhotos As String)

   ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:=sMyPath & sMyPhotos, _
                                                       LinkToFile:=msoFalse
                                                       SaveWithDocument:=msoTrue, _
                                                       Left:=50, _
                                                       Top:=50, _
                                                       Width:=100, _
                                                       Height:=100).Select

   ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
   ActiveWindow.Selection.ShapeRange.Align msoAlignMiddle, True

End Sub


ActiveWindow.Selection.SlideRange.Shapes("Diagram 5").Select 
ActiveWindow.Selection.ShapeRange.GroupItems(Index:=3).TextFrame.TextRange.Characters(Start:=1, Length:=0).Select




© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Prev