OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 21-12-2010, 11:39
kenpoist
Guest
 
Posts: n/a
Default Align Outside GMS

Hi All!
I've been cleaning up my files and found a text file with VBA code for aligning objects to the outside of another.
I gave it a try (this is pretty sweet idea), however, it won't work after selecting the side to align ("Private Sub AlignTopOutside_Click()").
Does anyone know who wrote this and/or can someone tell me how to fix my error.

Private Sub AlignBottomOutside_Click()
Sub Bottom()
Dim s As Shape, sr As ShapeRange
Dim y As Double

ActiveDocument.ReferencePoint = cdrBottomMiddle

Set sr = ActiveSelectionRange
Set s = sr(1)
sr.Remove 1

y = s.PositionY

ActiveDocument.ReferencePoint = cdrTopMiddle

boostStart "Align Bottom"
For Each s In sr
s.PositionY = y
Next s
boostFinish True, True
End Sub

Private Sub AlignLeftOutside_Click()
Sub Left1()
Dim s As Shape, sr As ShapeRange
Dim x As Double

ActiveDocument.ReferencePoint = cdrMiddleLeft

Set sr = ActiveSelectionRange
Set s = sr(1)
sr.Remove 1

x = s.PositionX

ActiveDocument.ReferencePoint = cdrMiddleRight

boostStart "Align Left"
For Each s In sr
s.PositionX = x
Next s
boostFinish True, True
End Sub

Private Sub AlignRightOutside_Click()
Sub Right()
Dim s As Shape, sr As ShapeRange
Dim x As Double

ActiveDocument.ReferencePoint = cdrMiddleRight

Set sr = ActiveSelectionRange
Set s = sr(1)
sr.Remove 1

x = s.PositionX

ActiveDocument.ReferencePoint = cdrMiddleLeft

boostStart "Align Right"
For Each s In sr
s.PositionX = x
Next s
boostFinish True, True
End Sub

Private Sub AlignTopOutside_Click()
Sub Top1()
Dim s As Shape, sr As ShapeRange
Dim y As Double

ActiveDocument.ReferencePoint = cdrTopMiddle

Set sr = ActiveSelectionRange
Set s = sr(1)
sr.Remove 1

y = s.PositionY

ActiveDocument.ReferencePoint = cdrBottomMiddle

boostStart "Align Top"
For Each s In sr
s.PositionY = y
Next s
boostFinish True, True
End Sub

Private Sub boostStart(Optional unDo$)
On Error Resume Next
If Len(unDo) Then ActiveDocument.BeginCommandGroup unDo
Optimization = True
EventsEnabled = False
ActiveDocument.SaveSettings
ActiveDocument.PreserveSelection = False
End Sub

Private Sub boostFinish(Optional ByVal endUndoGroup As Boolean = False, Optional ByVal doRedraw As Boolean = True)
On Error Resume Next
ActiveDocument.PreserveSelection = True
ActiveDocument.RestoreSettings
EventsEnabled = True
Optimization = False
If endUndoGroup Then ActiveDocument.EndCommandGroup

If doRedraw Then
CorelScript.RedrawScreen
ActiveWindow.Refresh
Application.Refresh
End If
End Sub
Reply With Quote
  #2  
Old 21-12-2010, 12:20
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Align Shapes

It looks like a modified version of my code posted here: better align object
The problem with the modified code is they have the Private Sub AlignBottomOutside_Click() and then another Sub Bottom(). The Sub should only be defined once. You need to remove one or the other depending how you are using it.

If you use the original code, everything should work fine.

-Shelby
Reply With Quote
  #3  
Old 22-12-2010, 07:19
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

Shelby, I love the idea of the boost sections. Seems a little more useful than just begin and end command groups.
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #4  
Old 22-12-2010, 09:05
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default boost

The boost Subs were written by the GREAT Os! So the big thanks goes to him.

-Shelby
Reply With Quote
Reply


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
Align Outside the Shape macrofan CorelDRAW/Corel DESIGNER VBA 2 14-11-2009 02:30
better align object cmjmmrp CorelDRAW/Corel DESIGNER VBA 5 29-05-2009 02:18
Align stroke on a path jod General 3 10-05-2007 21:07
Multiple Groups & Align Under kuty CorelDRAW/Corel DESIGNER VBA 2 17-08-2004 13:21
CorelDraw 12's Align Mark CorelDRAW/Corel DESIGNER VBA 8 16-07-2004 17:24


All times are GMT -5. The time now is 04:38.


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