Hey y'all,
Would there would be a way for me to make a macro that creates 1 cm margins? I'm aware of the "/tools/options/presets/one centimeter margin" thing, but I'd like the margins to be created with one click, and not having to change the Units to centimeters every time (I usually prefer working with pixels).
Help anyone?
oh and it's my first time here hehe.
Found this here. And with a little modification (see below)
Also see notes where to change the Units and distance
Sub addguides()
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 = cdrInch 'change to units desired
n = 1 '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
ActiveDocument.RestoreSettings
EventsEnabled = True
Optimization = False
Application.Refresh
ActiveWindow.Refresh
ActiveDocument.EndCommandGroup
'------------------------ Undo Group End ------------------------
ActiveDocument.ClearSelection
ActivePage.Layers(l).Activate
End Sub
You can try this (made on X5)
Sub Guides2()Dim p As Page, x#, y#, h#, w#, adu As String, adl As LayerActiveDocument.BeginCommandGroup ("Guides")adu = ActiveDocument.UnitSet adl = ActiveDocument.ActivePage.ActiveLayerActiveDocument.Unit = cdrMillimeterActivePage.GetBoundingBox x, y, w, hActivePage.GuidesLayer.Shapes.All.DeleteSet s1 = ActivePage.GuidesLayer.CreateGuideAngle(x + 10, 148.5, 90#)s1.MoveToLayer ActivePage.GuidesLayers1.Outline.Color.RGBAssign 0, 100, 0Set s2 = s1.Duplicate(w - 20, 0)Set s3 = ActivePage.GuidesLayer.CreateGuideAngle(0, y + 10, 0#)s3.MoveToLayer ActivePage.GuidesLayers3.Outline.Color.RGBAssign 0, 100, 0Set s4 = s3.Duplicate(0, h - 20)ActiveDocument.ClearSelectionActiveDocument.Unit = acuActiveDocument.EndCommandGroupEnd Sub
need to create guidlines outside of the page exactly o.5mm but when i am trying to change the n value to -0.5 then it shows me guide on 0.7mm please help.