I am upgrading from CorelDraw X5 to X7. I have an external program writen in Vb.Net and Visual Studio 2013. When I change the referance to use X7 form X5 and run the code below the box is created but the box.AlignToPageCenter does not work.Nothing happens the box 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
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 alternitive to this. I have a sample VS project but I can not find a way to upload it so it can be downloaded at http://www.cwebtechnologies.com/files/CorelDrawTest.zip
ThanksPaul
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)