I am writing a script in VBA that creates a drawing in CorelDraw. I am having trouble centering the text. Here is the code that works properly in CorelDraw's Macro editor:
Dim s2 As Object
Dim Txt As Object
Dim test As String
Dim returntest As String
returntest = "Test~Test1234~Test56~Test789"
test = Replace(returntest, "~", Chr(13))
Set s2 = CorelApp.ActiveLayer.CreateArtisticText(-7.75, (1 - 0.5) / 2, test)
Set Txt = s2.Text
Txt.Story.Font = "Swis721 BT"
Txt.Story.Size = 20
Txt.Story.LineSpacing = 75
Txt.Story.Alignment = cdrCenterAlignment
s2.Fill.UniformColor.CMYKAssign 0, 0, 0, 100
s2.Outline.SetNoOutline
s2.CenterX = s1.CenterX
s2.CenterY = s1.CenterY
s1 is simply a rectangle that is already defined. The problem is with "cdrCenterAlignment". VBA does not recognize it as a valid argument because it is referencing something that exists only within CorelDraw. I get "cdrCenterAlignment variable not defined" or "type mismatch" if I call it a string. How, if even possible, can I send this command/argument to CorelDraw while still working in Excel?
I ran into similar problems sending the same drawing to AutoCAD but was able to work around it by sending things to the Command line.
In your VBA code you can define it yourself:
Const cdrCenterAlignment = 3
https://community.coreldraw.com/sdk/api/draw/19/e/cdrAlignment