TextRange.MajorityFont 属性 (Publisher)
返回一个 Font 对象,该对象代表文字范围中使用最多的字体名称。
语法
表达式。MajorityFont
表达 一个代表 TextRange 对象的变量。
返回值
字体
示例
本示例创建一个新的文本框,将其用文字填充,检查使用最多的字体是否为 Tahoma,如果不是,将其更改为 Tahoma。
Sub SetFontName()
Dim intCount As Integer
With ActiveDocument.Pages(1).Shapes _
.AddTextbox(Orientation:=pbTextOrientationHorizontal, _
Left:=100, Top:=100, Width:=100, Height:=100) _
.TextFrame.TextRange
For intCount = 1 To 10
.InsertAfter NewText:="This is a test. "
Next intCount
If .MajorityFont <> "Tahoma" Then _
.Font.Name = "Tahoma"
End With
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。