Working with Guides in PPT 2013 and later
PowerPoint 2013 introduced the Guides collection, new guide features and VBA methods for working with them.
Here are a couple examples of working with Guides in VBA:
Add guides at specific positions
Adding guides at specific positions manually is somewhere about halfway between "Extreme Pain" and "Utterly Impossible". Rather than explain that, I'll just suggest that you try it: Position a vertical guide at exactly 42 points from the left edge of the slide. Be prepared for a fight. One that PowerPoint will win.
Or you could use a bit of VBA to create a whole grid of guides instantly.
Sub AddGuides() Dim HGuides As String Dim VGuides As String Dim x As Long Dim aGuideArray() As String ' Edit these to indicate where you'd like to put guides: ' Values are in points, 72 points to the inch ' Separate each value from the next with a pipe | character ' Horizontal guide positions: HGuides = "72|144|256.5" ' Vertical guide positions: VGuides = "10|20|30|40|50|60|70|80|90|100" With ActivePresentation ' nb ppHorizonatalGuide = 1; ppVerticalGuide = 2 ' nb to add guides to master rather than slides, ' use .SlideMaster.Guides.Add below ' in place of .Guides.Add ' First add the horizontal guides aGuideArray = Split(HGuides, "|") For x = LBound(aGuideArray) To UBound(aGuideArray) Guides.Add ppHorizontalGuide, CSng(aGuideArray(x)) Next ' and now the vertical guides aGuideArray = Split(VGuides, "|") For x = LBound(aGuideArray) To UBound(aGuideArray) .Guides.Add ppVerticalGuide, CSng(aGuideArray(x)) Next End With End Sub
Guides on slides or masters. Or both!
Where you used to have only one set of guides across the entire presentation, you can now have one set of guides on masters and a different set of guides on slides. This is handy because you can't accidentally move a master guide while working on slides.
This example copies all of the guides from the presentation (ie, the ones you see and can move in normal view) to the slide master:
Sub MoveGuidesToMaster() ' Run this to copy all of the current presentation guides ' to the slide master Dim x As Long With ActivePresentation For x = 1 To .Guides.Count .SlideMaster.Guides.Add .Guides(x).Orientation, .Guides(x).Position Next End With End Sub
Delete all guides
The next example deletes all guides from the presentation (but not the master). You might want to use it after using the first example above so you don't have double guides, one set from the master, one set in the presentation. Of course, you could use .SlideMaster.Guides(x).Delete to remove the guides from the slide master instead.
Sub DeletePresentationGuides() ' Run this to delete the guides in the presentation ' (but not those on master) Dim x As Long With ActivePresentation For x = .Guides.Count To 1 Step -1 .Guides(x).Delete Next End With End Sub
Guides in Color!
You can now assign different colors to guides. By default, guides on slide masters will be red, guides on slides will be light gray.
But they don't have to be. This snippet will make the first guide on slides green:
Sub GuideColor()
ActivePresentation.Guides(1).Color.RGB = RGB(0, 255, 0)
End Sub
The tricky bit here will be figuring out which guide is which. The index numbers (the number in parentheses after Guides) are assigned as the guides are created, vertical and horizontals intermixed in creation order.
See How do I use VBA code in PowerPoint? to learn how to use this example code.