PowerPoint VBA: Show or Hide Grid Lines

This PowerPoint VBA macro toggles visibility of grid-lines.

Macro Example

Sub ToggleGridLines()

  With Application
    .DisplayGridLines = Not .DisplayGridLines
  End With

End With

Description

Starts the With statement

Sub...

  With Application

The 3rd line starts the With…End With statement.

This statement tells PowerPoint that following any code will apply to the Application.

Application

The Application property returns the Application object that represents Microsoft PowerPoint application.

obj-PowerPoint-Global-Application

Toggles Show/Hide

Sub...

  With Application
    .DisplayGridLines = Not .DisplayGridLines

The 4th line toggles the Application.DisplayGridLines property.

Application.DisplayGridLines

The Application.DisplayGridLines property determines whether to display grid-lines in PowerPoint.

obj-PowerPoint-Application-DisplayGridLines

Not Operator

The Not operator switches a boolean value to its opposite.

Ends the With Structure

Sub...

  With Application
    .DisplayGridLines = Not .DisplayGridLines
  End With

The 5th line ends the With…End With statement.

After the 5th line is evaluated, this macro ends.

Sub ToggleGridLines()

  With Application
    .DisplayGridLines = Not .DisplayGridLines
  End With

End With

Properties

http://www.relief.jp/itnote/archives/powerpoint-vba-display-grid-lines.php

Apply to

  • PowerPoint 2013
  • PowerPoint 2010
  • PowerPoint 2007