So I recently updated to CorelDraw 2020 from X7. I'm moving over my macros and I've run into a view issues. My biggest problem right now is that I cant change a Rectangle Shape's corner radius / type without crashing CorelDraw. This error doesn't even bring up the VBA debugger with an error on the offending line of code in the macro. The following is the code being used in my macro that causes a crash:
Sub StartTest() '
Dim OrigSelection As ShapeRange Set OrigSelection = ActiveSelectionRange Dim s1 As Shape Set s1 = OrigSelection(1) s1.Rectangle.CornerType = cdrCornerTypeChamfer ' crash occurs here s1.Rectangle.RelativeCornerScaling = True s1.Rectangle.RadiusLowerLeft = 0.4 s1.Rectangle.RadiusLowerRight = 0.4 s1.Rectangle.RadiusUpperLeft = 0.4 s1.Rectangle.RadiusUpperRight = 0.4 End Sub
So after selecting a Rectangle shape in my document and running this macro I get a crash. I've even recorded a macro where I simply change the corner type to Chamfer and edit the radii and after replaying the macro it causes a crash.
My OS is Windows 7 by the way.
Any insights into this issue would be greatly appreciated!
Have you tried to use a different CornerType?
yes, the same applies for Rounded, Scallop, and Chamfer. Additionally, without changing the CornerType, setting a Rectangle's RadiusLowerLeft, RadiusLowerRight, RadiusUpperLeft, and RadiusUpperRight also causes CorelDraw 2020 to crash.
And finally, while looking for alternative options, CorelDraw 2020 crashed when trying to use a Rectangle's SetRadius and SetRoundness methods.
possible, have to convert rectangle into a curve and round nodes using Node.Fillet or Node.Chamfer/Scallop
An alternative I found (when needed) was to create another rectangle with rounded corners. But you must take care to recalculate, using the radius you want to obtain, like in the next code:
Dim sh As Shape, shR As Shape, radius As Double, rD As Long
Set sh = ActiveShape
ActiveDocument.Unit = cdrInch: Application.Unit = cdrInch
radius = 0.2 'inch
rD = CLng((sh.SizeWidth * sh.SizeHeight) / 2 * radius * 400) 'max 100
Set shR = ActiveLayer.CreateRectangle(sh.LeftX, sh.TopY, _
sh.LeftX + sh.SizeWidth, sh.TopY - sh.SizeHeight, rD, rD, rD, rD)
shR.Fill.UniformColor = sh.Fill.UniformColor
'and so on, if other properties are needed