我正在创建幻灯片并在每个幻灯片上插入一个大的(几个MB大小的)图像到现有的pptx
。我想使用另一个演示文稿的布局。我可以从模板中导入主文件,但是当我使用.ApplyTemplate("desiredTemplate")
时。但是,如何让新幻灯片具有导入的.ppLayoutTitleOnly
布局而不是powerpoint的原始TitleOnly
布局?
Private Sub PPTGeneratorAL(ByVal imageArr As List(Of String), ByVal alReportName As String)
Const sTemplate = "C:\temp\script\testtemplate2.potx"
Dim oApp As PowerPoint.Application
Dim oPres As PowerPoint.Presentation
Dim oSlide As PowerPoint.Slide
Dim scaleFactor As Decimal
oApp = New PowerPoint.Application()
oApp.Visible = True
oApp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized
oPres = oApp.Presentations.Open(alReportName)
oPres.Slides.Range(2).Delete()
oPres.Slides.Range(2).Delete()
oPres.Slides.Range(2).ApplyTemplate(sTemplate)
For Each slideImage In imageArr
'this next line is the one that's not doing what I want
oSlide = oPres.Slides.Add(3, PowerPoint.PpSlideLayout.ppLayoutTitleOnly)
'code to add the image to the slide here - this part works
oSlide = Nothing
Next slideImage
end sub
答案 0 :(得分:0)
我想出了一个解决方案:
oPres.Slides.Range(2).Delete()
oPres.Slides.Range(2).Delete()
oPres.Slides.Range.ApplyTemplate(sTemplate)
oPres.Slides(2).CustomLayout() = oPres.SlideMaster.CustomLayouts(2)
For Each slideImage In imageArr
oSlide=oPres.Slides.Add(3,PowerPoint.PpSlideLayout.ppLayoutTitleOnly)
oPres.Slides(3).CustomLayout() = oPres.SlideMaster.CustomLayouts(2)
oSlide = Nothing
Next slideImage