word-vba宏无法更改非英语单词的字体大小 [英] word-vba macro unable to change font size of non English words

查看:124
本文介绍了word-vba宏无法更改非英语单词的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Word 2007文档中,我手动选择了一个包含英语和英语的句子.多种字体大小的孟加拉语单词.当我在面板的字体大小"列表框中输入一些数值并按Enter时,整个句子的字体大小将成功更改(包括孟加拉语单词).

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).

但是,当我在VBA单词宏中选择相同的句子并在最后一行尝试

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?

  • 我也尝试遍历每个字符,但是得到了相同的结果.
  • 我需要坚持使用word-VBA,因为它是使用Chrome Web驱动程序硒的Web抓取程序的一部分.
  • 我还尝试了在手动创建的Word文档中使用带有Vrinda(Body CS)字体的手动键入的英语和孟加拉语混合单词的简单宏,结果是相同的.选择整个句子,但仅更改英语单词的字体.

尝试将近5天.将不胜感激任何建议.提前致谢.

Trying it for nearly 5 days. will appreciate any suggestion. Thanks in advance.

示例文本我很好,你很好吗?可以吗?"

Sample Text "I am Ok You are Ok আমিও ঠিক তুমিও ঠিক Is it ok"

推荐答案

Word区分格式为从左到右(LTR)的文本和格式为从右到左(RTL)的文本.我不熟悉书面(或口语)孟加拉语,但Word显然认为它是RTL.在对象模型(VBA)中,有一组单独的RTL字体属性-后缀Bi被添加到属性名称中.所以

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.

这篇关于word-vba宏无法更改非英语单词的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆