ResetLocale

 Corel Drawでは、アジア系、ラテン系、中東系と3つのグループでフォントを別々に設定できます。(Microsoft社のWordも欧文、和文、その他で設定できますよね)。
 これまで1バイト2バイトを入り乱れさせたときにどうもうまくフォントが設定できず、バグだ!と思っていましたが、「言語」の設定が変だったことにようやく気が付きました。
 このコードは、選択したオブジェクト(1つのみ)が段落テキストかアートテキストの場合、文字を1つずつチェックし、1バイト文字の場合は言語を(US)に、それ以外は(JP)に設定します。


Attribute VB_Name = "localeOnly"
Option Explicit

Sub Main()
' ResetLocale
' Copyright by Albatross (c)2003
' Ver 1.00 2003/10/28

    Dim ccode As Integer
    Dim wcounter As Integer
    Dim countmax As Integer
    Dim objtext As Text

    If ActiveDocument Is Nothing Then
        MsgBox "ドキュメントがありません", vbCritical, "Error"
        Exit Sub
    End If
    If Application.ActiveSelection.Shapes.Count <> 1 Then
        MsgBox "オブジェクトが選択されていないか、複数選択されています", vbCritical, "Error"
        Exit Sub
    End If
    If Application.ActiveSelection.Shapes(1).Type <> cdrTextShape Then
        MsgBox "選択されたオブジェクトはテキストではありません", vbCritical, "Error"
        Exit Sub
    End If
    
    Set objtext = Application.ActiveSelection.Shapes(1).Text
    countmax = Len(objtext.Story)
    For wcounter = 0 To countmax - 1
        ccode = AscW(objtext.Story.Range(wcounter, wcounter + 1).WideText)
        If ccode > -1 And ccode < 256 Then
            objtext.Story.Range(wcounter, wcounter + 1).LanguageID = cdrEnglishUS
        Else
            objtext.Story.Range(wcounter, wcounter + 1).LanguageID = cdrJapanese
        End If
    Next wcounter
End Sub

<<戻る