Slide 对象 (PowerPoint)Slide object (PowerPoint)

代表一个幻灯片。Represents a slide. Slides 集合包含演示文稿中的所有 Slide 对象。The Slides collection contains all the Slide objects in a presentation.

注释Remarks

备注

如果尝试返回对单张幻灯片的引用, 但最后是一个**SlideRange** 对象, 则不要混淆。Don't be confused if you are trying to return a reference to a single slide but you end up with a SlideRange object. 可以通过 Slide 对象或仅包含一张幻灯片的 SlideRange 集合表示单张幻灯片,具体取决于返回幻灯片引用的方式。A single slide can be represented either by a Slide object or by a SlideRangecollection that contains only one slide, depending on how you return a reference to the slide. 例如,如果使用 Add 方法创建和返回幻灯片引用,则可以通过 Slide 对象表示幻灯片。For example, if you create and return a reference to a slide by using the Add method, the slide is represented by a Slide object. 但是,如果使用 Duplicate 方法创建和返回幻灯片引用,则可以通过包含单张幻灯片的 SlideRange 集合表示幻灯片。However, if you create and return a reference to a slide by using the Duplicate method, the slide is represented by a SlideRange collection that contains a single slide. 适用于 Slide 对象的所有属性和方法也适用于包含单张幻灯片的 SlideRange 集合,所以,可以相同的方式使用返回的幻灯片,无论它是通过 Slide 对象或 SlideRange 集合表示。Because all the properties and methods that apply to a Slide object also apply to a SlideRange collection that contains a single slide, you can work with the returned slide in the same way, regardless of whether it is represented by a Slide object or a SlideRange collection.

以下示例说明如何执行下列操作:The following examples describe how to:

  • 返回一个通过名称、索引号或幻灯片 ID 号指定的幻灯片Return a slide that you specify by name, index number, or slide ID number

  • 返回选定范围中的幻灯片Return a slide in the selection

  • 返回指定的任意文档窗口或幻灯片放映窗口中当前显示的幻灯片Return the slide that's currently displayed in any document window or slide show window you specify

  • 新建幻灯片Create a new slide

示例Example

使用幻灯片(索引), 其中_索引_是幻灯片名称或索引号, 或使用FindBySlideID (索引), 其中_索引_是幻灯片 ID 号, 用于返回单个的slide对象。Use Slides (index), where index is the slide name or index number, or use Slides.FindBySlideID (index), where index is the slide ID number, to return a single Slide object. 以下示例设置活动演示文稿中第一张幻灯片的版式。The following example sets the layout for slide one in the active presentation.

ActivePresentation.Slides(1).Layout = ppLayoutTitle

以下示例设置 ID 号为 265 的幻灯片的版式。The following example sets the layout for the slide with the ID number 265.

ActivePresentation.Slides.FindBySlideID(265).Layout = ppLayoutTitle

使用所选内容. SlideRange (索引), 其中_索引_是选定内容中的幻灯片名称或索引号, 返回单个的幻灯片对象。Use Selection.SlideRange (index), where index is the slide name or index number within the selection, to return a single Slide object. 以下示例设置活动窗口选定范围中的第一张幻灯片的版式(假设至少选定一张幻灯片)。The following example sets the layout for slide one in the selection in the active window, assuming that there's at least one slide selected.

ActiveWindow.Selection.SlideRange(1).Layout = ppLayoutTitle

如果仅选择一张幻灯片,则可以使用 Selection.SlideRange 返回包含选定幻灯片的 SlideRange 集合。If there's only one slide selected, you can use Selection.SlideRange to return a SlideRange collection that contains the selected slide. 以下示例设置当前窗口当前所选对象中第一张幻灯片的版式(假设正好只选定一张幻灯片)。The following example sets the layout for slide one in the current selection in the active window, assuming that there's exactly one slide selected.

ActiveWindow.Selection.SlideRange.Layout = ppLayoutTitle

使用 Slide 属性返回指定文档窗口或幻灯片显示窗口视图中当前显示的幻灯片。Use the Slide property to return the slide that's currently displayed in the specified document window or slide show window view. 以下示例将第二个文档窗口中当前显示的幻灯片复制到剪贴板。The following example copies the slide that's currently displayed in document window two to the Clipboard.

Windows(2).View.Slide.Copy

使用 Add 方法可新建幻灯片并将其添加到演示文稿中。Use the Add method to create a new slide and add it to the presentation. 以下示例在当前演示文稿的开头添加一个标题幻灯片。The following example adds a title slide to the beginning of the active presentation.

ActivePresentation.Slides.Add 1, ppLayoutTitleOnly

方法Methods

名称Name
ApplyTemplateApplyTemplate
ApplyTemplate2ApplyTemplate2
ApplyThemeApplyTheme
ApplyThemeColorSchemeApplyThemeColorScheme
CopyCopy
CutCut
删除Delete
DuplicateDuplicate
ExportExport
MoveToMoveTo
MoveToSectionStartMoveToSectionStart
PublishSlidesPublishSlides
SelectSelect

属性Properties

名称Name
ApplicationApplication
BackgroundBackground
BackgroundStyleBackgroundStyle
ColorSchemeColorScheme
CommentsComments
CustomerDataCustomerData
CustomLayoutCustomLayout
设计Design
DisplayMasterShapesDisplayMasterShapes
FollowMasterBackgroundFollowMasterBackground
HasNotesPageHasNotesPage
HeadersFootersHeadersFooters
HyperlinksHyperlinks
LayoutLayout
MasterMaster
名称Name
NotesPageNotesPage
ParentParent
PrintStepsPrintSteps
sectionIndexsectionIndex
ShapesShapes
SlideIDSlideID
SlideIndexSlideIndex
SlideNumberSlideNumber
SlideShowTransitionSlideShowTransition
TagsTags
ThemeColorSchemeThemeColorScheme
TimeLineTimeLine

另请参阅See also

PowerPoint 对象模型引用PowerPoint Object Model Reference

支持和反馈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.