PowerPoint

Add Slides and Text to a Slide

Ease of Use

Intermediate

Version tested with

2002 

Submitted by:

Jacob Hilderbrand

Description:

This macro will add a slide to a PowerPoint presentation and it will add text to that slide. 

Discussion:

You may want to create several slides with similar text or you may have the text stored somewhere else. This macro shows how to create the slide and add text to it. 

Code:

instructions for use

			

Option Explicit Sub AddSlides() Dim Pre As Presentation Dim Sld As Slide Set Pre = ActivePresentation Set Sld = Pre.Slides.Add(Index:=Pre.Slides.Count + 1, Layout:=ppLayoutText) Sld.Shapes(1).TextFrame.TextRange = "Title of Slide" Sld.Shapes(2).TextFrame.TextRange = "Line 1" & vbNewLine & _ "Line 2" & vbNewLine & _ "Line 3" & vbNewLine & _ "Line 4" & vbNewLine End Sub

How to use:

  1. Open PowerPoint.
  2. Alt + F11 to open the VBE.
  3. Insert | Module.
  4. Paste the code in the Code Window that opens up.
  5. Close the VBE (Alt + Q or press the X in the top-right corner).
 

Test the code:

  1. Tools | Macro | Macros...
  2. Select AddSlides and press Run.
 

Sample File:

AddSlides.zip 7.46KB 

Approved by mdmackillop


This entry has been viewed 228 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express