PowerPoint presentations have slides.
Slides contain the information presented in a presentation.
Presentations without slides are empty files, and they are not very useful.

A presentation can have one or many slides.

Declare a slide object


You can add as many slide object variables as you want.


Set the slide variable to a new slide.


The prst1 variable is used in this example because we are adding the slide to a specific presentation.

Slide Index

In the above example, we are adding a slide with an index of "1".
This will position of the slide at the beginning of the presentation.

If there are 5 slides, and we add a slide with an index of "3", then the new slide will be placed as the third slide and the rest of the slides after 3 will be renumbered.

The index number in the Add statement is useful for positioning the slide as it is created. However, since index numbers are reassigned as slides are added and removed, you should not count on index numbers to identify specific slides.

Layout

In addition to assigning an index, you must assign a Layout to a new slide.

In this example, we have used ppLayoutBlank. This will create a blank slide.

Other possible layouts include ppLayoutText, ppLayoutChart, ppLayouttextAndClipArt or ppLayoutObjectAndText.


Referencing a Existing Slide


The same caveat applies to index numbers in slides as apply to index numbers in presentations.
It is better to use a slide's name instead of an index.


But slides only have names if you assign them.


Naming a new slide


This assigns the name MySlide to the slide we added.
The slide name or the slide index can be used to refer to the slide.


Both of the these statement are the same.

The name will always stay the same.
The index may change if other slides are added or removed.
Therefore, it is better practice to refer to the name instead of the index.



Slide Properties

There are several properties that apply to slides that are useful for the VBA programmer.

Layout

This is the layout assigned to a new slide when it is created.
PowerPoint requires a layout to be assigned to any new slide.
You can use ppLayoutBlank if you don't want to use a layout.



Name

This assigns a name to a slide.



SlideIndex

This property returns the index number of a slide.
This is a read-only value. You cannot change it.


The value of x will be the index number.


SlideID

All slides have a unique ID. This is NOT the same as the slide index.

x = sld1.SlideID

The Slide ID is read-only.
You can't assign a SlideId value, you can only retreive the ID value.
In this example, x will contain the ID number.
Unlike an index number, the SlideID will never change.


SlideNumber

The slide number is the number that will appear on the lower-right corner of the slide when displayed.
This is a read-only value.

x = sld1.SlideNumber



Slide Methods

Copy



Paste


In the above example, you can PASTE a slide to a specific position.
If a position is not specified, the slide will be pasted as the last slide of the presentation.


MoveTo


Move the slide to the 5th position in the presentation.

Delete












Copyright © 2006-2016, LQSystems,Inc. All rights reserved.


   Printer Friendly Page


Home