Any code to convert highlighted text properties to "fraction"

too many steps to do this. Can it be done with a macro?

Parents
No Data
Reply
  • What you are trying to do is a replacement of a sub string with another character defined in your character set. But this requires, that your character set supports this string. This is something which is supported in UniCode, where I'm not really familiar with. What I know so far is, that you need to do a syntax like:
    CurTxt = "Here we have 1/2 of 1/4 means 1/8"
    CurTxt = Replace(CurTxt, "1/2", ChrW(189))
    CurTxt = Replace(CurTxt, "1/4", ChrW(188))
    CurTxt = Replace(CurTxt, "1/8", ChrW(8539))
    Here you have to dig the web for more codes. Enjoy this!

    An always working method is to do the manipulation of the characters by yourself: You need to search for character position of the numerator, change its size to a smaller one and move it up. Then you have to find the position of the denominator and change the size as well. If you want you also may manipulate the font style of the divider.
    Here is a small example how you can do this:

    CurTxt = "1/4 divided by 1/2 equals 1/8"
    TxtSize = 40
    Set CurSh = CurLy.CreateArtisticText(20, 20, CurTxt, , , "Arial", TxtSize)

    ChrPos = 0
    Do
       ChrPos = InStr(ChrPos + 1, CurTxt, "/")
       If ChrPos > 0 Then
          SubPos = InStrRev(CurTxt, " ", ChrPos)
          With CurSh.Text.Story.Characters(SubPos + 1, ChrPos - SubPos - 1)
             .Size = TxtSize * 0.7
             .VertShift = TxtSize * 0.8
          End With
          With CurSh.Text.Story.Characters(ChrPos, 1)
             .Size = TxtSize * 0.5
             .VertShift = TxtSize * 0.4
          End With
          SubPos = InStr(ChrPos, CurTxt, " ")
          If SubPos = 0 Then SubPos = Len(CurTxt) + 1
          CurSh.Text.Story.Characters(ChrPos + 1, SubPos - ChrPos - 1).Size = TxtSize * 0.7
       End If
    Loop Until ChrPos = 0

Children
No Data