使用VB.NET从Powerpoint中的第二个幻灯片母版应用布局
我正在创建幻灯片,并在每张幻灯片上插入一个大的(几MB大小)图像到现有的使用VB.NET从Powerpoint中的第二个幻灯片母版应用布局,vb.net,layout,powerpoint,Vb.net,Layout,Powerpoint,我正在创建幻灯片,并在每张幻灯片上插入一个大的(几MB大小)图像到现有的pptx。不过我想使用另一个演示文稿的布局。我可以让母版从模板导入,但当我使用.ApplyTemplate(“desiredTemplate”)时。但是,如何使新幻灯片具有导入的.pplayouttittly版面,而不是powerpoint的原始标题版面 Private Sub PPTGeneratorAL(ByVal imageArr As List(Of String), ByVal alReportName As S
pptx
。不过我想使用另一个演示文稿的布局。我可以让母版从模板导入,但当我使用.ApplyTemplate(“desiredTemplate”)
时。但是,如何使新幻灯片具有导入的.pplayouttittly
版面,而不是powerpoint的原始标题
版面
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
我想出了一个解决办法:
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
我想出了一个解决方案:oPres.Slides.Range(2).Delete()oPres.Slides.Range(2).Delete()oPres.Slides.Range.ApplyTemplate(sTemplate)oPres.SlideMaster.CustomLayouts()=oPres.slide=oPres.Slides.Add(3,PowerPoint.PpSlideLayout.pplayout)oPres.slide(3).CustomLayout()=oPres.SlideMaster.CustomLayouts(2)oSlide=下一个slideImage无任何内容