Trouble setting Properties

Hello, I'm trying to use VB macro to set Text Properties in CorelDraw. I can successfully read all of them, but I cannot set any. Any idea how to do it? Regards, Paul

Parents
  • Please, try the next way:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    Sub testSetKerning()
       Dim sh As Shape
       Set sh = ActiveShape
       sh.Text.FontProperties.RangeKerning = 100
       With sh.Text.Story
            .WordSpacing = 200
            .CharSpacing = 10
            .LineSpacing = 150
        End With
    End Sub
    

    Select a text box having two lines, try running the code line by line, pressing F8 (with VBE window small enough) and see what's happening

    You can reset the characters spacing using the next code:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    Sub ResetCharSpacing()
        Dim tr As TextRange
        If ActiveShape Is Nothing Then
            MsgBox "Nothing selected", vbCritical
            Exit Sub
        End If
        
        If ActiveShape.Type <> cdrTextShape Then
            MsgBox "Make sure the a object is selected", vbCritical
            Exit Sub
        End If
        
        If ActiveShape.Text.IsEditing Then
            Set tr = ActiveShape.Text.Selection
            MsgBox "Unable to reset Range Kerning for selection", vbExclamation
        Else
            Set tr = ActiveShape.Text.Story
            ActiveShape.Text.FontProperties.RangeKerning = 0
        End If
        
        tr.WordSpacing = 100
        tr.CharSpacing = 0
        tr.LineSpacing = 100
    End Sub
Reply Children