OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-03-2003, 08:09
Craig Tucker
Guest
 
Posts: n/a
Default 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
Reply With Quote
  #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
  #3  
Old 11-03-2003, 13:27
Craig Tucker
Guest
 
Posts: n/a
Default

Hi Alex,
That's what I needed.
Thanks much,
Craig
Reply With Quote
  #4  
Old 12-03-2003, 11:57
Craig Tucker
Guest
 
Posts: n/a
Default 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...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Text ENCODE Craig Tucker CorelDRAW/Corel DESIGNER VBA 10 26-01-2005 13:59
Where does COrelPhotopaint 12 keeps its Globalmacros file? cyrilgupta Corel Photo-Paint VBA 1 08-11-2004 15:02
Special Rotate ddonnahoe CorelDRAW/Corel DESIGNER VBA 7 26-04-2004 12:20


All times are GMT -5. The time now is 01:29.


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