幻灯片.AddSlide 方法 (PowerPoint)

创建新幻灯片,将其添加到 幻灯片 集合,并返回幻灯片。

语法

expression. AddSlide( _Index_, _pCustomLayout_ )

表达 返回 幻灯片 对象的表达式。

参数

名称 必需/可选 数据类型 说明
Index 必需 Int 要添加的幻灯片的索引。
pCustomLayout 必需 CustomLayout 幻灯片的版式。

返回值

幻灯片

示例

以下示例说明如何使用 Add 方法将新幻灯片添加到 Slides 集合。 它在索引位置 2 处添加一张新幻灯片,该幻灯片具有与当前演示文稿中第一张幻灯片同样的版式。

Public Sub Add_Example() 
 
    Dim pptSlide As Slide 
    Dim pptLayout As CustomLayout 
 
    Set pptLayout = ActivePresentation.Slides(1).CustomLayout 
    Set pptSlide = ActivePresentation.Slides.AddSlide(2, pptLayout) 
 
End Sub

备注

如果您的Visual Studio解决方案包含 Microsoft.Office.Interop.PowerPoint的引用,此方法将映射到以下类型:

  • Microsoft.Office.Interop.PowerPoint.Slides.Add (int、Microsoft.Office.Interop.PowerPoint.PpSlideLayout)

  • Microsoft.Office.Interop.PowerPoint.Slides.AddSlide (int、Microsoft.Office.Interop.PowerPoint.CustomLayout)

另请参阅

幻灯片对象

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。