Sub insertimages()
Dim path1, path2, path3, path4 As String
Dim scale1, scale2, scale3, scale4 As Single
Dim perwidth1, perheight1, perwidth2, perheight2, perwidth3, perheight3, perwidth4, perheight4 As Single
Dim pic As Shape
Dim a1, a2, a3, a4, b1, b2, b3, b4 As Long
'Pictures'
path1 = "C:\Users\CS\Desktop\foto1.jpg"
path2 = "C:\Users\CS\Desktop\foto2.jpg"
path3 = "C:\Users\CS\Desktop\foto3.jpg"
path4 = "C:\Users\CS\Desktop\foto4.jpg"
'scale of each picture in percentage'
scale1 = 0.1
scale2 = 0.1
scale3 = 0.1
scale4 = 0.1
'position of each picture on the slide'
perwidth1 = 0
perheight1 = 0
perwidth2 = 0.3
perheight2 = 0.3
perwidth3 = 0.5
perheight3 = 0.5
perwidth4 = 0.7
perheight4 = 0.7
''''''''''''''''''''''''''''''''''''
'convert it in ppt'
a1 = perwidth1 * 958.11023646
a2 = perwidth2 * 958.11023646
a3 = perwidth3 * 958.11023646
a4 = perwidth4 * 958.11023646
b1 = perheight1 * 541.41732297
b2 = perheight2 * 541.41732297
b3 = perheight3 * 541.41732297
b4 = perheight4 * 541.41732297
ActivePresentation.Slides.Add 1, ppLayoutBlank
Set pic = ActivePresentation.Slides(1).Shapes.AddPicture(path1, False, True, a1, b1, -1, -1)
ActivePresentation.Slides(1).Shapes(1).ScaleWidth scale1, msoTrue
ActivePresentation.Slides(1).Shapes(1).LockAspectRatio = msoTrue
Set pic = ActivePresentation.Slides(1).Shapes.AddPicture(path2, False, True, a2, b2, -1, -1)
ActivePresentation.Slides(1).Shapes(2).ScaleWidth scale2, msoTrue
ActivePresentation.Slides(1).Shapes(2).LockAspectRatio = msoTrue
Set pic = ActivePresentation.Slides(1).Shapes.AddPicture(path3, False, True, a3, b3, -1, -1)
ActivePresentation.Slides(1).Shapes(3).ScaleWidth scale3, msoTrue
ActivePresentation.Slides(1).Shapes(3).LockAspectRatio = msoTrue
Set pic = ActivePresentation.Slides(1).Shapes.AddPicture(path4, False, True, a4, b4, -1, -1)
ActivePresentation.Slides(1).Shapes(4).ScaleWidth scale4, msoTrue
ActivePresentation.Slides(1).Shapes(4).LockAspectRatio = msoTrue
ActivePresentation.Slides.Range(1).Cut
ActivePresentation.Slides.Paste -1
End Sub
No comments:
Post a Comment