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 27-07-2017, 07:34
dungbtl's Avatar
dungbtl dungbtl is offline
Senior Member
 
Join Date: Apr 2004
Posts: 138
Default Objects Inside ~ Centered Within

There are objects inside a shape, square, circle or whatever.

How to group them and become centered within that shape?

I guess they would become grouped if they aren't and center within?

See pic below.
Attached Images
 
Reply With Quote
  #2  
Old 13-03-2018, 03:29
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 430
Default

Try this (seemed to work using X6):

Code:
Sub AlignGroupToObject()

Dim sr As ShapeRange
Dim s as shape
 
If ActiveDocument Is Nothing Or ActiveSelection.Shapes.Count = 0 Then Exit Sub

Set sr = ActiveSelection.Shapes.all
ActiveSelection.Shapes(1).RemoveFromSelection

Set s = ActiveSelection.Shapes.all.Group

sr.CreateSelection

s.AlignToShape cdrAlignHCenter, ActiveSelection.Shapes(1)
s.AlignToShape cdrAlignVCenter, ActiveSelection.Shapes(1)

End Sub
Note: The target object is the last to be selected.
Reply With Quote
  #3  
Old 18-03-2018, 06:06
dungbtl's Avatar
dungbtl dungbtl is offline
Senior Member
 
Join Date: Apr 2004
Posts: 138
Default

Thanks Nobody

It works in X4 & 2017 just fine.

Pint of Guinness to your right
Reply With Quote
  #4  
Old 19-03-2018, 10:40
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 430
Default

Glad it worked, thanks for the Guinness, haven't had a real one in over 20 years!
Reply With Quote
  #5  
Old 20-03-2018, 04:17
shark shark is offline
Senior Member
 
Join Date: Aug 2010
Location: Russia, Belgorod
Posts: 145
Default slightly improved code (:

Code:
Sub CenterGroup()
Dim s As Shape, sr As ShapeRange
    Set sr = ActiveSelectionRange: If sr.Count = 0 Then Beep: Exit Sub
    Set s = sr.FirstShape: sr.Remove 1 'align to bottom shape
    sr.AlignRangeToShape cdrAlignHCenter + cdrAlignVCenter, s
    sr.Group
End Sub

Last edited by shark; 20-03-2018 at 07:13. Reason: group shaperange
Reply With Quote
  #6  
Old 22-10-2018, 05:43
dungbtl's Avatar
dungbtl dungbtl is offline
Senior Member
 
Join Date: Apr 2004
Posts: 138
Default

@shark

Wooo... many months later.

Yes this code is good as well.

Need some code fixing for 2018 version
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
include inside groups gorgo CorelDRAW/Corel DESIGNER VBA 1 10-12-2012 23:01
Page centered at 0,0 CWCN General 1 15-06-2010 14:49
How do I make Past Inside? Aloninet General 1 20-07-2006 06:16
How to place a bitmap inside text or other objects? Alex FAQ 1 24-05-2005 12:01
Select objects inside another shelbym CorelDRAW/Corel DESIGNER VBA 1 25-11-2003 17:01


All times are GMT -5. The time now is 10:25.


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