Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF

Toggle a design grid on and off

This will allow you to add or remove a design grid on a slide.
By editiing the values as shown below, you can change the spacing and color of the grid.

It's not a snap-to grid and you can't lock it in position, but if you accidentally move the gridlines, you can easily toggle them off and back on again.

Run Sub ToggleGrid to use the macros. It figures out whether the gridlines need to be added or removed, then does so.

Option Explicit
' Edit these two values to change the grid spacing in inches
Const dVspacing As Double = 0.25
Const dHspacing As Double = 0.25
' Edit these three values to change the RGB color of the grid lines
Const lGridColorRed As Long = 225
Const lGridColorGreen As Long = 225
Const lGridColorblue As Long = 225

Sub ToggleGrid()
    If Len(ActiveWindow.Selection.SlideRange(1).Tags("GRIDDED")) > 0 Then
        Call RemoveGrid
    Else
        Call CreateGrid
    End If
End Sub
Function CreateGrid()
' Creates gridlines
' Edit the values below to change spacing and color

    Dim oSh As Shape
    Dim oSl As Slide
    Dim x As Double

    Dim dBeginX As Double
    Dim dBeginY As Double
    Dim dEndX As Double
    Dim dEndY As Double

    ' these hold dVspacing and dHspacing converted to points
    Dim dVspace As Double
    Dim dHspace As Double

    dVspace = dVspacing * 72
    dHspace = dHspacing * 72

    dBeginX = 0
    dBeginY = 0
    dEndX = ActivePresentation.PageSetup.Slidewidth
    dEndY = ActivePresentation.PageSetup.Slideheight

    Set oSl = ActiveWindow.Selection.SlideRange(1)
    With oSl
        ' add vertical gridlines
        For dBeginX = 0 To ActivePresentation.PageSetup.Slidewidth
            Set oSh = oSl.Shapes.AddLine(dBeginX, dBeginY, dBeginX, dEndY)
            With oSh
                ' Change RGB value here:
                .Line.ForeColor.RGB = RGB(lGridColorRed, lGridColorGreen, lGridColorblue)
                Call .Tags.Add("GRIDLINE", "YES")
            End With
            dBeginX = dBeginX + dHspace
        Next
        ' add horizontal gridlines
        dBeginX = 0
        dBeginY = 0
        For dBeginY = 0 To ActivePresentation.PageSetup.Slideheight
            Set oSh = oSl.Shapes.AddLine(dBeginX, dBeginY, dEndX, dBeginY)
            With oSh
                ' Change RGB value here:
                .Line.ForeColor.RGB = RGB(225, 225, 225)
                Call .Tags.Add("GRIDLINE", "YES")
            End With
            dBeginY = dBeginY + dVspace
        Next
        ' Mark the slide so we know that it's gridded
        Call .Tags.Add("GRIDDED", "YES")
    End With

End Function

Function RemoveGrid()
    Dim oSh As Shape
    Dim x As Long
    For x = ActiveWindow.Selection.SlideRange(1).Shapes.Count To 1 Step -1
        Set oSh = ActiveWindow.Selection.SlideRange(1).Shapes(x)
        If Len(oSh.Tags("GRIDLINE")) > 0 Then
            oSh.Delete
        End If
    Next
    ' Mark the slide so we know that it's gridded
    ActiveWindow.Selection.SlideRange(1).Tags.Delete ("GRIDDED")

End Function

See How do I use VBA code in PowerPoint? to learn how to use this example code.


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2015 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.
Español    Deutsch    Français    Português    Italiano    Nederlands    Greek    Japanese    Korean    Chinese

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Toggle a design grid on and off
http://www.pptfaq.com/FAQ00742_Toggle_a_design_grid_on_and_off.htm
Last update 07 June, 2011
Created: