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 19-12-2014, 10:41
BlackNight BlackNight is offline
Junior Member
 
Join Date: Jun 2012
Posts: 10
Default t AlignToPageCenter adn AlignAndDistribute do not work in X7

I am upgrading from CorelDraw X5 to X7. I have an external program written in Vb.Net. When I change the reference to use X7 form X5 and run the code below the AlignToPageCenter does not work. The box is created but the box.AlignToPageCenter does not work, nothing happens to the box it does not move. I have tried box.AlignAndDistribute but that throws an Access violation error. I also need to align text to the center of the box but in X7 that does not work either using ThisLine.AlignToShape(just, box, CorelDRAW.cdrTextAlignOrigin.cdrTextAlignBoundingBox)


I understand that I could simply do something like box = CorelApp.ActiveLayer.CreateRectangle2(0 + 0.045, CorelDoc.MasterPage.BottomY + 0.045, (CorelDoc.MasterPage.SizeWidth - 0) - 0.09, CorelDoc.MasterPage.SizeHeight - 0.09)
to place the red box centered on the page but this is a siplified example of what I am doing. The issue is that AlignToPageCenter adn AlignAndDistribute do not work in X7. What is the alternative to this. I have uploaded the VS 2013 solution if it helps.


Any help on this would be greatly appreciated Thanks
Paul




CorelApp.Windows.CloseAll()
CorelApp.Application.Visible = True


CorelDoc = CorelApp.CreateDocument()


CorelDoc.Resolution = 1200

CorelDoc.Unit = CorelDRAW.cdrUnit.cdrInch
CorelApp.ActiveWindow.ActiveView.SetViewPoint(1.0#, 0.5, 100)
CorelDoc.MasterPage.SetSize(2.0#, 2.0#)
CorelDoc.MasterPage.Orientation = CorelDRAW.cdrPageOrientation.cdrLandscape
CorelDoc.MasterPage.PrintExportBackground = True
CorelDoc.MasterPage.Bleed = 0.0#
CorelDoc.MasterPage.Background = CorelDRAW.cdrPageBackground.cdrPageBackgroundNone



Dim boxColor As New CorelDRAW.Color
boxColor.CMYKAssign(0, 100, 100, 0)

Dim box As CorelDRAW.Shape
'box = CorelApp.ActiveLayer.CreateRectangle2(0 + 0.014, CorelDoc.MasterPage.TopY, (CorelDoc.MasterPage.SizeWidth - 0) - 0.09, CorelDoc.MasterPage.SizeHeight - 0.09)
box = CorelApp.ActiveLayer.CreateRectangle2(0 + 0.014, CorelDoc.MasterPage.CenterX, (CorelDoc.MasterPage.SizeWidth - 0) - 0.09, CorelDoc.MasterPage.SizeHeight - 0.09)
box.Outline.SetProperties(Color:=boxColor)
box.Name = "Box"
box.Fill.ApplyNoFill()
box.Outline.Width = 0.014 * 1

'box.AlignToPageCenter(CorelDRAW.cdrAlignType.cdrAlignVCenter, CorelDRAW.cdrTextAlignOrigin.cdrTextAlignBoundingBox)

box.AlignAndDistribute(VGCore.cdrAlignDistributeH.cdrAlignDistributeHDistributeCenter, VGCore.cdrAlignDistributeV.cdrAlignDistributeVDistributeCenter, VGCore.cdrAlignShapesTo.cdrAlignShapesToCenterOfPage)
Attached Files
File Type: zip CorelDrawTest.zip (536.8 KB, 282 views)
Reply With Quote
  #2  
Old 12-01-2015, 14:31
BlackNight BlackNight is offline
Junior Member
 
Join Date: Jun 2012
Posts: 10
Default Anybody??

Anybody?? Did I stump everybody?
Reply With Quote
  #3  
Old 12-01-2015, 20:14
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,782
Blog Entries: 11
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 AlignAndDistribute

AlignToPageCenter has been broken since X6.1 I believe, and yes it is still broken in X7.3. You are on the right track to use AlignAndDistribute. You just need to make sure you are using the AlignCenter and not the DistributeCenter. Looking at your code, here is the corrected version that will work:
Code:
 box.AlignAndDistribute(VGCore.cdrAlignDistributeH.cdrAlignDistributeHAlignCenter, VGCore.cdrAlignDistributeV.cdrAlignDistributeVAlignCenter, VGCore.cdrAlignShapesTo.cdrAlignShapesToCenterOfPage)
Hope that gets you all fixed up,

-Shelby
Reply With Quote
  #4  
Old 06-02-2015, 09:38
BlackNight BlackNight is offline
Junior Member
 
Join Date: Jun 2012
Posts: 10
Default

Shelby thanks for the reply. Did not see this till now. I tried your code but I get the same error.

"An unhandled exception of type 'System.AccessViolationException' occurred in CorelDrawTest.exe
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Any thoughts?

Thanks
Paul
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
why it can't work? engandy CorelDRAW/Corel DESIGNER VBA 1 04-10-2008 23:38
won't work doodedoo Calendar Wizard 7 06-12-2006 20:09
Can't get my puppy to work thedays6 Calendar Wizard 1 25-07-2006 12:22
Whether the VBA can work with Unicode . Dino CorelDRAW/Corel DESIGNER VBA 5 27-08-2003 16:13
VBA does not work with my CD 10 ! jobar CorelDRAW/Corel DESIGNER VBA 1 24-08-2003 12:38


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


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