8
votes

Please consider the following piece of code

With ActivePresentation
    Set sldNewSlide = .Slides.Add(.Slides.Count + 1, ppLayoutBlank)
    With sldNewSlide
    Set shpCurrShape = .Shapes.AddTextbox(msoTextOrientationHorizontal, 25, 50, 50, 200)

        With shpCurrShape
           With .TextFrame.TextRange

              '------------ Below is an ARABIC string
              .Text = ChrW$(&H6A9) & ChrW$(&H64A) & ChrW$(&H641) & " " & ChrW$(&H62D) & ChrW$(&H627) & ChrW$(&H644) & ChrW$(&H643)

              With .Font
                 .Name = "someFontName" '-------------- THIS LINE IS NOT WORKING
                 .Size = 65
              End With

           End With
        End With

    End With
End With

As indicated above, the font of arabic text is not being changed. Font change works well when the textbox contains english text. In case there is mixed arabic & english text, the english font is changed but arabic text stays in the default font (i.e Arial).

This code was working fine in Office 2003, but I came across this problem when trying to run in Office 2007/2010. I have double checked, the font I'm trying to specify is installed on the computer.

Although I have tested with arabic script languages only (arabic/urdu/persian etc), but I guess this problem will come up when dealing with any non-latin-script language.

Any suggestions? seems like a bug in later versions of ms office.

PS. setting the textbox language as suggested by @Steve (.LanguageID = msoLanguageIDArabic) has no effect :(

2
Good question, upvote, must be encouraged.Siddharth
When I ran this same code (PPT 2010, Win7/64-bit) and used Simplified Arabic as the font name, it did apply the font to the text. Whether it works beyond that, I don't know, since I don't have Arabic installed as an editing language in either Windows or Office. I'm guessing that you'd need both, and would also want to set the text's language (after "With .TextFrame.TextRange" add ".LanguageID = msoLanguageIDArabic"Steve Rindsberg
@Ammar is this solved already? if not please comment :)bonCodigo

2 Answers

2
votes

I found the answer myself. There are different Name properties in the Font class for different scripts. Here is a list of all Font members. In my case, I had to use NameComplexScript property. Incorporating this change, the code works like a charm

.Font.NameComplexScript = "someFontName" 
0
votes

Here is a similar case and this solution was given for a Chinese Font :) and can be used for any given that you know the CharSet code as well as the supporting Font Name as not every font will have the support for all language charsets..

In your case you need to find the charset you would like to use for Arabic and the supportive Font Name (set it according to the following sample). You will see the results in the run time.

UserForm1.TextBox2.Font.Charset = 134    '--CHINESESIMPLIFIED_CHARSET
UserForm1.TextBox2.Font.Name = ChrW(&H5B8B) + ChrW(&H4F53) '-- 宋体 SimSun font

UserForm1.TextBox2.Text = ChrW(37446)
strTxt2 = UserForm1.TextBox2.Text
'notice that ChrW(9246) produces a different character in Chinese
UserForm1.TextBox2.Text = strTxt2 & " " & ChrW(9246)