Skip to content
本页内容

查找(Find)

查找对象 Find,是代表查找操作的执行条件

Find 对象的属性和方法对应于 “查找和替换” 对话框中的选项

方法列表

方法说明
取消搜索结果高亮
搜索并高亮文本

ClearHitHighlight()

取消搜索结果高亮

语法

表达式.ActiveDocument.Find.ClearHitHighlight()

表达式:文档类型应用对象

示例

js
//@file=base.docx
async function example() {
  await instance.ready()

  const app = instance.Application

  // 取消搜索结果高亮
  await app.ActiveDocument.Find.ClearHitHighlight()
}

Execute()

搜索并高亮文本

语法

表达式.ActiveDocument.Find.Execute()

表达式:文档类型应用对象

参数

属性数据类型默认值必填说明
Text
String
-
查找文本
ShowHighlight
Boolean
true
是否高亮显示搜索结果

示例

js
//@file=base.docx
async function example() {
  await instance.ready()

  const app = instance.Application

  // 搜索并高亮文本
  await app.ActiveDocument.Find.Execute('test', true)
}