Table of contents
TOC
折叠目录
展开目录

TextRange.Characters 方法 (发布服务器)TextRange.Characters Method (Publisher)

office 365 dev account|上次更新日期: 2018/3/13
|
3 参与人员

返回TextRange对象,该对象表示指定的文本字符子集。Returns a TextRange object that represents the specified subset of text characters.

语法Syntax

表达式字符开始长度expression. Characters( Start, Length)

_expression_A 变量,表示内容的TextRange对象。_expression_A variable that represents a TextRange object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
启动Start必需RequiredLongLong返回范围中的第一个字符。The first character in the returned range.
LengthLength可选OptionalLongLong要返回的字符数。默认值为 1。The number of characters to be returned. Default is 1.

返回值Return Value

TextRangeTextRange

注解Remarks

如果Start参数大于指定文本中的字符数,则返回的范围从指定范围中的最后一个字符开始。If Start is greater than the number of characters in the specified text, the returned range starts with the last character in the specified range.

如果Length参数大于从指定起始字符到文本末尾的字符数,则返回的范围包含所有这些字符。If Length is greater than the number of characters from the specified starting character to the end of the text, the returned range contains all those characters.

示例Example

本示例设置当前文档中第一页上的第一个形状的文字,然后将前两个字符设置为字号 15 磅,加粗字体。This example sets the text for the first shape on the first page in the active document, and then sets the font of the first two characters to 15 points and bold.

Sub CharRange() 
 Dim rngCharacters As TextRange 
 Set rngCharacters = Application.ActiveDocument.Pages(1).Shapes(1) _ 
 .TextFrame.TextRange.InsertBefore(NewText:="Hello World.") 
 With rngCharacters.Characters(Start:=1, Length:=2).Font 
 .Size = 15 
 .Bold = msoTrue 
 End With 
End Sub
© 2018 Microsoft