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 :(
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With