RulerGuide Object

Microsoft Publisher Visual Basic

RulerGuide Object

Page RulerGuides
RulerGuide

Represents a grid line used to align objects on a page. The RulerGuide object is a member of the RulerGuides collection.

Using the RulerGuide object

Use the Add method of the RulerGuides collection to create a new ruler grid line. Use the Item property to reference a ruler guide. Use the Position property to change the position of a grid line, and use the Delete method to remove a grid line. This example creates a new ruler guide, moves it, and then deletes it.

Sub AddChangeDeleteGuide()
    Dim rgLine As RulerGuide
    With ActiveDocument.Pages(1).RulerGuides
        .Add Position:=InchesToPoints(1), _
            Type:=pbRulerGuideTypeVertical

        MsgBox "The ruler guide position is at one inch."

        .Item(1).Position = InchesToPoints(3)
        MsgBox "The ruler guide is now at three inches."

        .Item(1).Delete
        MsgBox "The ruler guide has been deleted."
    End With
End Sub