guideline

i am trying to create guideline with below mentioned code on outside of the page on all 4 side of 0.5mm exactly but unable to  make it complete please help me

Sub label()

Dim D As Document

Dim p As PageSize

Dim x As Long, y As Long

Dim l As String

Dim n As Double

ActiveDocument.Unit = cdrMillimeter 'change to units desired

n = -0.5 'equals 1/2"

'------------------------ Undo Group Start ------------------------

ActiveDocument.BeginCommandGroup "Undo action description"

Optimization = True

EventsEnabled = False

ActiveDocument.SaveSettings

ActiveDocument.PreserveSelection = False

l = ActiveLayer.Name

x = ActivePage.SizeWidth - n

y = ActivePage.SizeHeight - n

ActivePage.Layers("Guides").CreateGuideAngle x, y, 0 ' Horizontal

ActivePage.Layers("Guides").CreateGuideAngle x, y, 90 ' Vertical

x = ActivePage.SizeWidth - ActivePage.SizeWidth + n

y = ActivePage.SizeHeight - ActivePage.SizeHeight + n

ActivePage.Layers("Guides").CreateGuideAngle x, y, 0 ' Horizontal

ActivePage.Layers("Guides").CreateGuideAngle x, y, 90 ' Vertical

ActiveDocument.RestoreSettings

EventsEnabled = True

Optimization = False

Application.Refresh

ActiveWindow.Refresh

ActiveDocument.EndCommandGroup

'------------------------ Undo Group End ------------------------

ActiveDocument.ClearSelection

ActivePage.Layers(l).Activate

End Sub

Parents
No Data
Reply
  • wrong data type for x and y

    Long (long integer) variables are stored as signed 32-bit (4-byte) numbers ranging in value from -2,147,483,648 to 2,147,483,647. The type-declaration character for Long is the ampersand (&).

    change
    x as long to x#
    y as long to y#

Children