![]() |
|
#1
|
|||
|
|||
|
Whether the VBA can work with Unicode .
Code:
Sub Test()
Dim Name As String, T As Shape
Name = InputBox("Input Name")
Set T = ActivePage.TextFind("Fields", False)
With ActiveShape.Text
.Contents = Name
End With
End Sub
I think that VBA for CorelDraw does not support Unicode. |
|
#2
|
||||
|
||||
|
Dino,
The answer is both "Yes" and "No". CorelDRAW is not yet a true Unicode application, so it doesn't handle the text through Unicode per se. However it still can support multiple code pages in the same document, so you still can show Cyrillic, Central European, Western and other characters at the same time. CorelDRAW 11 has expanded its object model with advanced text handling messages which automatically convert Unicode characters from VBA (you need to use Shape.Text.Story, for example, instead of the old Shape.Text.Contents property). However if you are still under CorelDRAW 10 or 9, you will need to use a "hack" I explained in the following thread: Special Characters |
|
#3
|
|||
|
|||
|
Thank, Alex!
Your consutation very much has helped me. |
|
#5
|
|||
|
|||
|
I follow Dino's source code and change to text.shape.story to get value,
which I input. But, I can not see right text in that shape. I use traditional Chinese Windows 2000 OS and input traditional chinese. It seem unicode problems, Do I need to convert to Unicode before I use Text.Shape.Story? |
|
#6
|
|||
|
|||
|
I know Shape.text.story return a TextRange object, which has WideText and Text propority. As my opinion, the difference between two propority is WideText use unicode. When I used WideText, I found follow problems:
1:Everything is fine If I change TextRange.WideText with mix Chinese text(had Converted to Unicode) as single font type, which means Text include Chinese character, number and english character, but they are same font. At this situition, I check TextRange.CharSet and LanguageID, the value as follow. CharSet:136 (Big5) LanguageID: 1028 () 2:the text is invisiable when I change TextRange.WideText with original WideText. The code as follow Code:
Sub TestChangeText11()
Dim strInput As String
Dim strUnicode As String
Dim strBig5 As String
Dim oDocument As Document
Dim oPage As Page
Dim oShape As Shape
Dim oTextRange As TextRange
Dim oNewTextRange As TextRange
'strInput = InputBox("Input")
Set oDocument = Application.ActiveDocument
Set oPage = oDocument.ActivePage
Set oShape = oPage.FindShape(, , 14727) '14727; '8
If oShape Is Nothing Then
MsgBox "Can not find shape"
Else
Set oTextRange = oShape.Text.Story
strUnicode = oTextRange.WideText
'I write Unicode To Big 5 converter
strBig5 = UnicodeToBig5(strUnicode)
MsgBox "CharSet:" & oTextRange.CharSet & vbCrLf & "LanguageID:" & oTextRange.LanguageID
'the result: CharSet:0
' LanguageID:-1
MsgBox "Text:" & strBig5
oTextRange.WideText = Big5ToUnicode(strBig5)
strUnicode = oTextRange.WideText
strBig5 = UnicodeToBig5(strUnicode)
MsgBox "CharSet:" & oTextRange.CharSet & vbCrLf & "LanguageID:" & oTextRange.LanguageID
'the result: CharSet:0
' LanguageID:1033
MsgBox "Text:" & strBig5
End If
End Sub
The most strange thing is that every thing is fine when the first character of original text is chinese character. Otherwise, the text is invisible in CorelDraw when the first character of original text if non-chinese, including number and english character. At this situition, I selected text and edit it in CorelDraw, I found chinese character became blank, and only english character and number show. I think CorelDraw doesn't know I change mixed text. These problems didn't appear in CorelDraw 10 |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| delete vba project from cdr file | hotairballoon | CorelDRAW/Corel DESIGNER VBA | 1 | 18-05-2005 09:08 |
| Text ENCODE | Craig Tucker | CorelDRAW/Corel DESIGNER VBA | 10 | 26-01-2005 13:59 |
| CD 10, VBA not returning true outline width | Webster | CorelDRAW/Corel DESIGNER VBA | 1 | 24-11-2004 17:09 |
| VBA does not work with my CD 10 ! | jobar | CorelDRAW/Corel DESIGNER VBA | 1 | 24-08-2003 12:38 |
| Detect if VBA is installed (an answer and a question) | reanan | CorelDRAW/Corel DESIGNER VBA | 3 | 04-12-2002 14:35 |