IsEqual 方法 (Word)Selection.IsEqual method (Word)

如此 如果此方法应用于所选内容等于与 Range 参数指定的范围。True if the selection to which this method is applied is equal to the range specified by the Range argument.


expressionexpression. IsEqual( _Range_ )

expression:必需。expression Required. 表示 Selection 对象的变量。A variable that represents a Selection object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
RangeRange 必需Required RangeRange 与当前选择范围进行比较的范围。The range to compare with the current selection.

返回值Return value



此方法比较起始字符和结束字符的位置以及文字部分的类型。This method compares the starting and ending character positions and the story type. 如果所选内容和 Range 参数所指定的对象的所有三项都相同,则这两个对象相等。If all three of these items are the same for both the selection and the object specified by the Range argument, the objects are equal.


以下示例对活动文档第二段和选择范围进行比较。This example compares the selection with the second paragraph in the active document. 如果选择范围与第二段不相同,则选择第二段。If the selection isn't equal to the second paragraph, the second paragraph is selected.

If Selection.IsEqual(ActiveDocument _ 
 .Paragraphs(2).Range) = False Then 
End If

另请参阅See also

Selection 对象Selection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.