AddSlide 方法 (PowerPoint)Slides.AddSlide method (PowerPoint)

创建新的幻灯片,将其添加到 Slides 集合,然后返回幻灯片。Creates a new slide, adds it to the Slides collection, and returns the slide.


expressionexpression. AddSlide( _Index_, _pCustomLayout_ )

_表达式_一个返回一个幻灯片对象的表达式。expression An expression that returns a Slides object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
IndexIndex 必需Required IntInt 要添加的幻灯片的索引。The index of the slide to be added.
pCustomLayoutpCustomLayout 必需Required CustomLayoutCustomLayout 幻灯片的版式。The layout of the slide.

返回值Return value



以下示例说明如何使用 Add 方法将新幻灯片添加到 Slides 集合。The following example shows how to use the Add method to add a new slide to the Slides collection. 它在索引位置 2 处添加一张新幻灯片,该幻灯片具有与当前演示文稿中第一张幻灯片同样的版式。It adds a new slide in index position 2 that has the same layout as the first slide in the active presentation.

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. PowerPoint参考, 则此方法映射到以下类型:If your Visual Studio solution includes the Microsoft.Office.Interop.PowerPoint reference, this method maps to the following types:

  • microsoft. PpSlideLayout (int, (int, ".) (int, office)Microsoft.Office.Interop.PowerPoint.Slides.Add(int, Microsoft.Office.Interop.PowerPoint.PpSlideLayout)

  • AddSlide (int, Microsoft. CustomLayout 中的 "."。)Microsoft.Office.Interop.PowerPoint.Slides.AddSlide(int, Microsoft.Office.Interop.PowerPoint.CustomLayout)

另请参阅See also

幻灯片对象Slides Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.