Presentations are
.ppt files.
The
Presentations collection contains all open
.ppt files.
Declare a presentation object
Dim prst1 as Presentation
We declare the variable
prst1 to be assigned to a specific presentation (PowerPoint file)
Set the presentation object to a NEW presentation
Set prst1 = Presentations.Add
This will open a
new, blank .ppt file.
The variable
prst1 will be assigned to this new PowerPoint file.
The new file will not have a name until it is saved.
Set the presentation object to an EXISTING presentation
Set prst1 = Presentations.Open("c:\Sales2003.ppt")
This will open an
existing .ppt file and assign the presentation variable to the file.
Set the presentation object to the Active Presentation
Set prst1 = ActivePresentation
If a PowerPoint file is already open, this will set the presentation variable to the
currently selected PowerPoint file.
Set the presentation object to an already open presentation
Set prst1 = Presentations.Index(1)
OR
Set prst1 = Presentations(1)
(These two statements are identical)
This will set the presentation variable to the PowerPoint file with an
index of
1.
All open PowerPoint files (.ppt) are assigned an
index when they are opened.
The
index will be a number from
1 to the
total number of open PowerPoint files.
You cannot rely on knowing the index number of an open PowerPoint file.
Index numbers are assigned automatically as PowerPoint files are opened and closed.
It is best to reference a Presentation by its name.
Set the presentation object by its file name
Set prst1 = Presentations("Presentations.ppt")
OR
Set prst1 = Presentations("Presentations")
(These two statements are identical)
The file extension is
optional, since it will be .ppt.
Do not include the path.
You
do not have to assign the presentation to variable.
However you will then have to use the full presentation string in your code.
By using a variable for each open presentation, you only have to use
the variable name to refer to a specific presentation.
As we add Slides and Shapes the references can get very long.
Using a variable name will greatly simplify your code.
Saving a presentation
prst1.Save
prst1.SaveAs "c:\NewPresentation.ppt"
If you use the
"Save" option, the presentation will be saved under its existing name.
If the presentation was opened as a new presentation, a
"SaveAs" dialog box will be
displayed to ask for a file name.