Share via


RulerGuides Object

Publisher Developer Reference

A collection of RulerGuide objects that represents a gridline used to align objects on a page.

Example

Use the Add method of the RulerGuides collection to add ruler gridlines to the RulerGuides collection. This example creates horizontal ruler guides and vertical ruler guides every half inch on the first page of the active publication.

Visual Basic for Applications
  Sub SetRulerGuides()
    Dim intCount As Integer
    Dim intPos As Integer
    With ActiveDocument.Pages(1).RulerGuides
        For intCount = 1 To 16
            intPos = intPos + 36
             .Add Position:=intPos, Type:=pbRulerGuideTypeVertical
        Next intCount
        intPos = 0
        For intCount = 1 To 21
            intPos = intPos + 36
             .Add Position:=intPos, Type:=pbRulerGuideTypeHorizontal
        Next intCount
    End With
End Sub

Use the Count property to return the total number of ruler guides, horizontal and vertical, in the collection. The following example uses the Count property to create a loop that deletes each of the ruler guides in the collection.

Visual Basic for Applications
  Sub RemoveAllGuides()
    Dim intCount As Integer
    With ActiveDocument.Pages(1).RulerGuides
        For intCount = 1 To .Count
            .Item(1).Delete
        Next intCount
    End With
End Sub

See Also