|
楼主 |
发表于 2020-10-18 19:54
|
显示全部楼层
老师,有个问题,导入的图不是按编号,全打乱了,例如,我的图是1.jpg~21.jpg,现在导入后不是这个顺序。
Sub 插入相册()
Dim Width As Single, Height As Single
With ActivePresentation.PageSetup
Width = .SlideWidth: Height = .SlideHeight
End With
Filewidth = (Width)
Fileheight = (Height)
Call del
Dim oPPT As Presentation
Dim oSlide As Slide
Dim oCL As CustomLayout
Dim Shp As Shape
Dim myFile
Dim filearr()
Set oPPT = PowerPoint.ActivePresentation
'spath = PowerPoint.ActivePresentation.path & "\pic\"
spath = "C:\Users\Administrator\Downloads\ppt\改好\相册\"
myFile = Dir(spath & "*.jpg")
Do While myFile <> ""
ReDim Preserve filearr(i)
filearr(i) = myFile
i = i + 1
myFile = Dir
Loop
With oPPT
For i = 0 To UBound(filearr)
Set oCL = .Slides(1).CustomLayout
Set oSlide = .Slides.AddSlide(i + 2, oCL)
Set Shp = oSlide.Shapes.AddPicture(spath & filearr(i), msoFalse, msoTrue, 0, 0, Filewidth, Fileheight)
Next
End With
End Sub
|
|