Trouble setting up Text properties VBA

Hello,

I'm trying to create a macro for X6 that will set up various text settings in CorelDraw. Some of them are available in the Object Parameters docker in the Character section. I figured out that these are stored in the Sty.Character.Style Properties. I successfully managed to create a macro that read these. Now I know which ones to change and what values should I assign. The problem is I cannot set these. The snippet below is supposed to assign values to 6 Params and then reads them. Problem is they remain unchanged. Any idea why?

Dim my_object As Shape
For Each my_object In ActiveSelectionRange.Shapes
If my_object.Type = cdrTextShape Then
my_object.Style.Character.Style.SetProperty "kern", 1
my_object.Style.Character.Style.SetProperty "lnum", 1
my_object.Style.Character.Style.SetProperty "onum", 0
my_object.Style.Character.Style.SetProperty "palt", 1
my_object.Style.Character.Style.SetProperty "pnum", 1
my_object.Style.Character.Style.SetProperty "tnum", 0

MsgBox my_object.Style.Character.Style.GetPropertyAsString("kern") & " " & _
my_object.Style.Character.Style.GetPropertyAsString("lnum") & " " & _
my_object.Style.Character.Style.GetPropertyAsString("onum") & " " & _
my_object.Style.Character.Style.GetPropertyAsString("palt") & " " & _
my_object.Style.Character.Style.GetPropertyAsString("pnum") & " " & _
my_object.Style.Character.Style.GetPropertyAsString("tnum")
End If
Next my_object

Regards, Paul

  • try use another properties:

    my_object.Properties("kern", 1) = 254 'random value

    MsgBox  my_object.Properties("kern", 1)

    • Do you only try setting/storing (custom) properties? 

      Don't you try changing the text specific existing properties?

      Is this "kern" something related to the text Kerning property, or not?

      • What I'm trying to do is to create a macro that will adjust various text settings, including kerning method for numbers (there are several types for it). These setting are stored in properties defined in Corel. I found out that the ones that I need to set are those mentioned: kern, lnum, onum, palt, pnum, tnum. These are not user defined properties - they are already defined for each Text Shape. However as I said I can read those flags but cannot change them.

      • Guys, thank you for your suggestions. They did not help me directly, but at least inspired me to look in proper place. The solution is:

        Instead of changing properties here:

        my_object.Style.Character.Style.SetProperty "kern", 1

        One has to change it here:

        my_object.Text.Story.ObjectStyle.Character.Style.SetProperty "kern", 1

        And then the all of the sudden:

        MsgBox my_object.Style.Character.Style.GetPropertyAsString("kern")

        will print "1" instead of any random value. Text kerning changes too.