问题
In a word 2007 document, I manually select a sentence containing both English & Bengali words of multiple font size. When I enter some numeric value in Font size list-box in the panel and press Enter, the whole sentence font size is changed successfully (including Bengali words).
However when I select the same sentence in VBA word macro and in final line try
Selection.font.Size=8
only English words' font size gets changed. What is the problem?
- I also tried to loop through each characters, but got the same result.
- I need to stick to word-VBA as it is part of a web scrapping program using chrome web-driver selenium.
- I also tried simple macro in a manually created word document with manually typed mixed English and Bengali words with Vrinda (Body CS) font and the result was same. Whole sentence get selected but only English words fonts get changed.
Trying it for nearly 5 days. will appreciate any suggestion. Thanks in advance.
Sample Text "I am Ok You are Ok আমিও ঠিক তুমিও ঠিক Is it ok"
回答1:
Word differentiates between text formatted as left-to-right (LTR) and text formatted as right-to-left (RTL). I'm not familiar with written (or spoken) Bengali, but Word apparently considers it to be RTL. In the object model (VBA) there's a separate set of Font properties for RTL - the suffix Bi
is added to the property name. So
Selection.Font.Size = 8
Selection.Font.SizeBi = 8
Should take care of both languages.
来源:https://stackoverflow.com/questions/52472173/word-vba-macro-unable-to-change-font-size-of-non-english-words