OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Special Characters (http://forum.oberonplace.com/showthread.php?t=92)

Craig Tucker 11-03-2003 08:09

Special Characters
 
Hi All,
How do you pass special characters into Corel via VB.
I need to do something like the following...
.text.contents = ® or .text.contents = ©
Thanks much, Craig

Alex 11-03-2003 13:12

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

Craig Tucker 11-03-2003 13:27

Hi Alex,
That's what I needed.
Thanks much,
Craig

Craig Tucker 12-03-2003 11:57

Special Characters
 
Alex,
After running some test, I found that I was passing the special codes in like ® so by just issueing
s.Text.Contents = Replace(lcReplace, "Â", "")
fixes the special characters for ©, ®, etc...
Do you see anything wrong with doing this?

I don't know why  was being passed - I'm going to pull it out before passing the array to my VB dll.
However, after pulling the  out,
s.Text.Contents = "©" seems to work in CorelDRAW 10.
Craig...


All times are GMT -5. The time now is 20:34.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com