View Single Post
  #2  
Old 11-03-2003, 13:12
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default Re: Special Characters

Craig,

This should work OK in CorelDRAW 11 if you use the new text objects:

Code:
ActiveShape.Text.Story = "©"
In CorelDRAW 10 you need to use a little hack. Basically, you need to get an ASCII code of the character and then create a Unicode character using the single-byte code. You do this with using VBA's Asc and ChrW functions respectively:

Code:
ActiveShape.Text.Contents = ChrW$(Asc("©"))
If you want to assign more than one character, you need to process each character in the string this way. You can use the following function to convert a normal VBA string into something CorelDRAW 10 can use to assign to a text object:

Code:
Function GetWideString(s As String) As String
    Dim p As String, i As Long, c As String
    p = ""
    For i = 1 To Len(s)
        c = Mid$(s, i ,1)
        p = p & ChrW$(Asc(c))
    Next i
    GetWideString = p
End Function
Then you can use it as follows:

Code:
ActiveShape.Text.Contents = GetWideString("©®")
When you try get back the text from CorelDRAW and want to analyze it in VB/VBA, you should do a reverse transformation using AscW and Chr functions:

Code:
Function GetNormalString(s As String) As String
    Dim p As String, i As Long, c As String
    p = ""
    For i = 1 To Len(s)
        c = Mid$(s, i ,1)
        p = p & Chr$(AscW(c))
    Next i
    GetNormalString = p
End Function
HTH
Reply With Quote