Hello,
I want to apply a different character style to some characters of an artistic text in CorelDRAW 2024.
Following the help from here, and here I made the next script:
Sub Test3() Dim t As Text Dim s As Shape Dim s2 As Shape Dim st As Styles Dim d As Document Set d = CreateDocument Set s2 = d.ActiveLayer.CreateArtisticText(4, 6, "text for creating a style", , , "Arial", 36, cdrTrue) Set st = d.StyleSheet.CreateStyleFromShape(s2, "character", "Test style", True) Set s = d.ActiveLayer.CreateArtisticText(4, 5, "This is a test.") Set t = s.Text MsgBox "The text between characters 10 and 14 is: " & vbCr & t.Range(10, 14).Text t.Range(10, 14).Case = cdrAllCapsFontCase t.Range(10, 14).ApplyStyle "Test style"End Sub
The last line with ApplyStyle doesn't do anything, the selected characters remains with the original formating.
Am I doing something wrong?
I've had a similar problem. Sometimes styles created on the fly via macros don't seem to stick.
I'll have to save the document and reopen before the style works.
Maybe the VBA gurus will chime in with their views! : )