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 09-03-2018, 10:02
L_G_D L_G_D is offline
Member
 
Join Date: Apr 2009
Posts: 31
Default Align object to center of page?

I have an old macro I'm trying to update to work in Corel Draw 2017. It's a fairly simple one to draw basic shapes like rectangles and circles. The issue I'm having is getting the object to center on the page once it's drawn. I'm using the code:

(code to get size and options from dialog)
Set s = ActiveLayer.CreateRectangle2(0, 0, width, height, rradius, rradius, rradius, rradius)
(more code to set colors and such)
s.AlignToPageCenter cdrAlignHCenter + cdrAlignVCenter


And that used to work fine, but now that code places the object in the lower left corner of the page, and then draws any subsequent objects aligned to the top edge of the previous object and they continue up the page that way. If I close the file and start a new one, then the drawn objects start again in the lower left corner and work their way up from there.

I've tried changing the type of align setting to the various options, but they all place the object in the lower left of the page.
Reply With Quote
  #2  
Old 10-03-2018, 03:20
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 429
Default

I doubt this will make a difference but have you tried setting the reference point at the beginning of your code:

Code:
ActiveDocument.ReferencePoint = cdrCenter
Reply With Quote
  #3  
Old 12-03-2018, 15:07
L_G_D L_G_D is offline
Member
 
Join Date: Apr 2009
Posts: 31
Default

Thanks, but that doesn't seem to make any difference. I guess I'll have to figure another way to get something centered.
Reply With Quote
  #4  
Old 13-03-2018, 09:28
L_G_D L_G_D is offline
Member
 
Join Date: Apr 2009
Posts: 31
Default

OK, I can't get the AlignToPageCenter command to work at all, not sure if it's broken or what. But after recording a macro and hitting the "P" key to center an object on the page, it comes up with the following command, which works:

s.AlignAndDistribute 3, 3, 2, 0, False, 2

After digging deep into the help file (which isn't very helpful if you don't have a master's degree in computer programming) I figured out that means to center the object on the page, don't distribute, and don't include the outline.

Well, it works, and I can now continue in getting my macros updated to work in Draw 2017 (can't we just call it version 19 already?) and move on to the more complicated macros. Hopefully they won't be too much hassle to get working.
Reply With Quote
  #5  
Old 13-03-2018, 17:32
knowbodynow knowbodynow is offline
Senior Member
 
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 429
Default

Glad you got it working., Can't find anything about an AlignAndDistribute command in X6 help, guess it is new. It's always annoying and time-consuming when old, trusted methods are broken by upgrades. I gave up on upgrading when Corel introduced new terms of agreement with X6 service pack one. I won't buy Corel products as long as they need to phone home monthly in order to work. Best of luck with your other macros.
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 To Edge of Page? knowbodynow CorelDRAW/Corel DESIGNER VBA 2 17-11-2014 20:43
Group > Center > all Layers to page dungbtl Macros/Add-ons 3 09-06-2011 09:57
Get all object in one page use C++ nathan CorelDRAW/Corel DESIGNER VBA 12 27-09-2010 11:03
better align object cmjmmrp CorelDRAW/Corel DESIGNER VBA 5 29-05-2009 02:18
How to duplicate an object along common center Alex FAQ 2 03-05-2005 14:46


All times are GMT -5. The time now is 06:57.


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