OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-12-2016, 10:09
mtracy mtracy is offline
Member
 
Join Date: Jun 2012
Location: Niceville, Florida
Posts: 31
Default Distribute shapes to page

I've come up with my own little macro to distribute shapes evenly across a rectangle either horiz or vertically. If you use the distribute docker you can already "distribute across the page" but it places the outer shapes on the edge of the page. My macro sets equal distances across the rectangle including edges.

Simply select your shapes that are inside the rectangle then shift select your rectangle and run the appropriate macro

Works great for aligning/distributing paragraph text
................
Sub DistributeHorizWithin()
Dim sr As ShapeRange, s As Shape
Dim x As Double, y As Double, w As Double, h As Double
ActiveDocument.BeginCommandGroup "DistributeHorizWithin"
Set sr = ActiveSelectionRange
If sr.Count = 0 Then Exit Sub
sr.GetBoundingBox x, y, w, h
sr.Add ActiveLayer.CreateLineSegment(x, y, x, y + h / 5)

ActiveShape.Name = ("LS1")

sr.Add ActiveLayer.CreateLineSegment(x, y, x, y + h / 5)
ActiveShape.Move w / 1, 0

ActiveShape.Name = ("LS2")
sr.AddToSelection
sr(1).RemoveFromSelection
ActiveSelectionRange.Distribute cdrDistributeHSpacing
ActivePage.Shapes.FindShape("LS1").Delete
ActivePage.Shapes.FindShape("LS2").Delete
ActiveDocument.EndCommandGroup
End Sub

Sub DistributeVertWithin()
Dim sr As ShapeRange, s As Shape
Dim x As Double, y As Double, w As Double, h As Double
ActiveDocument.BeginCommandGroup "DistributeVertWithin"
Set sr = ActiveSelectionRange
If sr.Count = 0 Then Exit Sub
sr.GetBoundingBox x, y, w, h

sr.Add ActiveLayer.CreateLineSegment(x, y, x + h / 5, y)

ActiveShape.Name = ("LS1")

sr.Add ActiveLayer.CreateLineSegment(x, y, x + h / 5, y)
ActiveShape.Move 0, h / 1

ActiveShape.Name = ("LS2")
sr.AddToSelection
sr(1).RemoveFromSelection
ActiveSelectionRange.Distribute cdrDistributeVSpacing
ActivePage.Shapes.FindShape("LS1").Delete
ActivePage.Shapes.FindShape("LS2").Delete
ActiveDocument.EndCommandGroup
End Sub
Reply With Quote
Reply

Tags
distribute, macro, paragraph text


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
X6.1 Align & Distribute changes PAnderson CorelDRAW/Corel DESIGNER VBA 7 21-09-2012 01:56
distribute in pages buga Macros/Add-ons 4 28-02-2011 13:13
Shapes outside page bounds automatically move to Desktop Layer Janga General 5 16-06-2010 15:52
How to distribute the program? ricky0721 CorelDRAW/Corel DESIGNER VBA 3 26-03-2008 10:26
how to distribute a macro file mgmcs Macros/Add-ons 4 25-05-2006 08:23


All times are GMT -5. The time now is 13:07.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com