PowerPoint Macro: Changing the Pen Color All Presentations

This PowerPoint VBA macro changes the pen color.

Macro Example

Sub ChangingPenColor()

  Dim prs As Presentation
 
  For Each prs In Presentations
    prs.SlideShowSettings.PointerColor.RGB = RGB(0, 255, 0)
  Next prs

End Sub

Description

Variable Declaration

Sub...

  Dim prs As Presentation

The 3rd line declares an object variable named prs represents a Presentation object.

The Presentation object represents a single PowerPoint presentation.

obj-PowerPoint-Presentation

Starts Looping

Sub...

  Dim prs As Presentation

  For Each prs In Presentations

The 5th line starts to loop through all the elements (=Presentation) of a collection (=Presentations).

The Application.Presentations property returns the Presentations collection object.

obj-PowerPoint-Application-Presentations

The Presentations property is a member of the PowerPoint.Global class, so we can omit the Application property.

obj-PowerPoint-Global-Presentations

The Presentations is a collection of all the Presentation objects those are currently open in PowerPoint.

obj-PowerPoint-Presentations

Changing the Pen Color

Sub...

  Dim prs As Presentation
 
  For Each prs In Presentations
    prs.SlideShowSettings.PointerColor.RGB = RGB(0, 255, 0)

The 6th line changes the pen color.

Presentation.SlideShowSettings

    prs.SlideShowSettings...

The Presentation.SlideShowSettings property returns a SlideShowSettings object that represents the slide show settings for the presentation.

obj-PowerPoint-Presentation-SlideShowSettings

SlideShowSettings.PointerColor

    prs.SlideShowSettings.PointerColor...

The SlideShowSettings.PointerColor property returns the pointer color (pen color) for the specified presentation as a ColorFormat object.

obj-PowerPoint-SlideShowSettings-PointerColor

ColorFormat.RGB (PointerColor.RGB)

    prs.SlideShowSettings.PointerColor.RGB...

The PointerColor.RGB (ColorFormat.RGB property) returns or sets the red-green-blue (RGB) value of the specified color.

obj-PowerPoint-ColorFormat-RGB

In this macro, I am setting R=0, G=225, and B=0 to ColorFormat.RGB property.

Loops Back

Sub...

  Dim prs As Presentation
 
  For Each prs In Presentations
    prs.SlideShowSettings.PointerColor.RGB = RGB(0, 255, 0)
  Next prs

The 7th line loops back to get the next presentation.
After every presentation evaluated, this macro ends.

Sub ChangingPenColor()

  Dim prs As Presentation
 
  For Each prs In Presentations
    prs.SlideShowSettings.PointerColor.RGB = RGB(0, 255, 0)
  Next prs

End Sub

Properties

http://www.relief.jp/itnote/archives/powerpoint-vba-change-pen-color.php

Apply to

  • PowerPoint 2013
  • PowerPoint 2010
  • PowerPoint 2007