word package

Word.Application

表示应用程序对象。

Word.Body

表示文档或节的正文。

Word.Comment

表示文档中的注释。

Word.CommentCollection

包含 Word.Comment 对象的集合。

Word.CommentContentRange
Word.CommentReply

表示文档中的批注答复。

Word.CommentReplyCollection

包含 Word.CommentReply 对象的集合。 表示一个批注线程中的所有批注答复。

Word.ContentControl

表示内容控件。 内容控件是文档中绑定的、有可能添加标签的区域,它们充当特定类型的内容的容器。 各个内容控件可能包含诸如图像、表格或格式化文本段落等内容。 目前,仅支持格式文本、纯文本和复选框内容控件。

Word.ContentControlCollection

包含 Word.ContentControl 对象的集合。 内容控件是文档中绑定的、有可能添加标签的区域,它们充当特定类型的内容的容器。 各个内容控件可能包含诸如图像、表格或格式化文本段落等内容。 目前,仅支持格式文本和纯文本内容控件。

Word.CustomProperty

表示自定义属性。

Word.CustomPropertyCollection

包含 Word.CustomProperty 对象的集合。

Word.CustomXmlPart

表示自定义 XML 部件。

Word.CustomXmlPartCollection

包含 Word.CustomXmlPart 对象的集合。

Word.CustomXmlPartScopedCollection

包含具有特定命名空间的 Word.CustomXmlPart 对象的集合。

Word.Document

Document 对象是顶层对象。 Document 对象包含一个或多个节、内容控件以及包含文档内容的正文。

Word.DocumentCreated

DocumentCreated 对象是由 Application.CreateDocument 创建的顶级对象。 DocumentCreated 对象是一个特殊的 Document 对象。

Word.DocumentProperties

表示文档属性。

Word.Field

表示一个字段。

Word.FieldCollection

包含 Word.Field 对象的集合。

Word.Font

表示字体。

Word.InlinePicture

表示嵌入式图片。

Word.InlinePictureCollection

包含 Word.InlinePicture 对象的集合。

Word.List

包含 Word.Paragraph 对象的集合。

Word.ListCollection

包含 Word.List 对象的集合。

Word.ListItem

表示段落列表项格式。

Word.Paragraph

表示选定内容、区域、内容控件或文档正文中的单个段落。

Word.ParagraphCollection

包含 Word.Paragraph 对象的集合。

Word.Range

表示文档中的一个连续区域。

Word.RangeCollection

包含 Word.Range 对象的集合。

Word.RequestContext

RequestContext 对象有助于向 Word 应用程序发出请求。 由于 Office 加载项和 Word 应用程序在两个不同的进程中运行,因此需要请求上下文才能从外接程序访问 Word 对象模型。

Word.SearchOptions

指定要包括在搜索操作中的选项。 若要详细了解如何在 Word JavaScript API 中使用搜索选项,请阅读 使用搜索选项在 Word 加载项中查找文本。

Word.Section

表示 Word 文档中的一节。

Word.SectionCollection

包含文档的 Word.Section 对象的集合。

Word.Setting

表示加载项的设置。

Word.SettingCollection

包含 Word.Setting 对象的集合。

Word.Style

表示 Word 文档中的样式。

Word.Table

表示 Word 文档中的表。

Word.TableBorder

指定边框样式。

Word.TableCell

表示 Word 文档中的表格单元格。

Word.TableCellCollection

包含文档的 TableCell 对象的集合。

Word.TableCollection

包含文档的 Table 对象的集合。

Word.TableRow

表示 Word 文档中的一行。

Word.TableRowCollection

包含文档的 TableRow 对象的集合。

接口

Word.Interfaces.AnnotationCollectionData

一个接口,用于描述通过调用 annotationCollection.toJSON()返回的数据。

Word.Interfaces.AnnotationCollectionUpdateData

用于更新对象上的 AnnotationCollection 数据的接口,用于 在 中使用 annotationCollection.set({ ... })

Word.Interfaces.AnnotationData

一个接口,用于描述通过调用 annotation.toJSON()返回的数据。

Word.Interfaces.BodyData

一个接口,用于描述通过调用 body.toJSON()返回的数据。

Word.Interfaces.BodyLoadOptions

表示文档或节的正文。

Word.Interfaces.BodyUpdateData

用于更新对象上的 Body 数据的接口,用于 在 中使用 body.set({ ... })

Word.Interfaces.CheckboxContentControlData

一个接口,用于描述通过调用 checkboxContentControl.toJSON()返回的数据。

Word.Interfaces.CheckboxContentControlUpdateData

用于更新对象上的 CheckboxContentControl 数据的接口,用于 在 中使用 checkboxContentControl.set({ ... })

Word.Interfaces.CollectionLoadOptions

提供仅加载集合的一部分成员的属性的方法。

Word.Interfaces.CommentCollectionData

一个接口,用于描述通过调用 commentCollection.toJSON()返回的数据。

Word.Interfaces.CommentCollectionLoadOptions

包含 Word.Comment 对象的集合。

Word.Interfaces.CommentCollectionUpdateData

用于更新对象上的 CommentCollection 数据的接口,用于 在 中使用 commentCollection.set({ ... })

Word.Interfaces.CommentContentRangeData

一个接口,用于描述通过调用 commentContentRange.toJSON()返回的数据。

Word.Interfaces.CommentContentRangeLoadOptions
Word.Interfaces.CommentContentRangeUpdateData

用于更新对象上的 CommentContentRange 数据的接口,用于 在 中使用 commentContentRange.set({ ... })

Word.Interfaces.CommentData

一个接口,用于描述通过调用 comment.toJSON()返回的数据。

Word.Interfaces.CommentLoadOptions

表示文档中的注释。

Word.Interfaces.CommentReplyCollectionData

一个接口,用于描述通过调用 commentReplyCollection.toJSON()返回的数据。

Word.Interfaces.CommentReplyCollectionLoadOptions

包含 Word.CommentReply 对象的集合。 表示一个批注线程中的所有批注答复。

Word.Interfaces.CommentReplyCollectionUpdateData

用于更新对象上的 CommentReplyCollection 数据的接口,用于 在 中使用 commentReplyCollection.set({ ... })

Word.Interfaces.CommentReplyData

一个接口,用于描述通过调用 commentReply.toJSON()返回的数据。

Word.Interfaces.CommentReplyLoadOptions

表示文档中的批注答复。

Word.Interfaces.CommentReplyUpdateData

用于更新对象上的 CommentReply 数据的接口,用于 在 中使用 commentReply.set({ ... })

Word.Interfaces.CommentUpdateData

用于更新对象上的 Comment 数据的接口,用于 在 中使用 comment.set({ ... })

Word.Interfaces.ContentControlCollectionData

一个接口,用于描述通过调用 contentControlCollection.toJSON()返回的数据。

Word.Interfaces.ContentControlCollectionLoadOptions

包含 Word.ContentControl 对象的集合。 内容控件是文档中绑定的、有可能添加标签的区域,它们充当特定类型的内容的容器。 各个内容控件可能包含诸如图像、表格或格式化文本段落等内容。 目前,仅支持格式文本和纯文本内容控件。

Word.Interfaces.ContentControlCollectionUpdateData

用于更新对象上的 ContentControlCollection 数据的接口,用于 在 中使用 contentControlCollection.set({ ... })

Word.Interfaces.ContentControlData

一个接口,用于描述通过调用 contentControl.toJSON()返回的数据。

Word.Interfaces.ContentControlLoadOptions

表示内容控件。 内容控件是文档中绑定的、有可能添加标签的区域,它们充当特定类型的内容的容器。 各个内容控件可能包含诸如图像、表格或格式化文本段落等内容。 目前,仅支持格式文本、纯文本和复选框内容控件。

Word.Interfaces.ContentControlUpdateData

用于更新对象上的 ContentControl 数据的接口,用于 在 中使用 contentControl.set({ ... })

Word.Interfaces.CritiqueAnnotationData

一个接口,用于描述通过调用 critiqueAnnotation.toJSON()返回的数据。

Word.Interfaces.CustomPropertyCollectionData

一个接口,用于描述通过调用 customPropertyCollection.toJSON()返回的数据。

Word.Interfaces.CustomPropertyCollectionLoadOptions

包含 Word.CustomProperty 对象的集合。

Word.Interfaces.CustomPropertyCollectionUpdateData

用于更新对象上的 CustomPropertyCollection 数据的接口,用于 在 中使用 customPropertyCollection.set({ ... })

Word.Interfaces.CustomPropertyData

一个接口,用于描述通过调用 customProperty.toJSON()返回的数据。

Word.Interfaces.CustomPropertyLoadOptions

表示自定义属性。

Word.Interfaces.CustomPropertyUpdateData

用于更新对象上的 CustomProperty 数据的接口,用于 在 中使用 customProperty.set({ ... })

Word.Interfaces.CustomXmlPartCollectionData

一个接口,用于描述通过调用 customXmlPartCollection.toJSON()返回的数据。

Word.Interfaces.CustomXmlPartCollectionLoadOptions

包含 Word.CustomXmlPart 对象的集合。

Word.Interfaces.CustomXmlPartCollectionUpdateData

用于更新对象上的 CustomXmlPartCollection 数据的接口,用于 在 中使用 customXmlPartCollection.set({ ... })

Word.Interfaces.CustomXmlPartData

一个接口,用于描述通过调用 customXmlPart.toJSON()返回的数据。

Word.Interfaces.CustomXmlPartLoadOptions

表示自定义 XML 部件。

Word.Interfaces.CustomXmlPartScopedCollectionData

一个接口,用于描述通过调用 customXmlPartScopedCollection.toJSON()返回的数据。

Word.Interfaces.CustomXmlPartScopedCollectionLoadOptions

包含具有特定命名空间的 Word.CustomXmlPart 对象的集合。

Word.Interfaces.CustomXmlPartScopedCollectionUpdateData

用于更新对象上的 CustomXmlPartScopedCollection 数据的接口,用于 在 中使用 customXmlPartScopedCollection.set({ ... })

Word.Interfaces.DocumentCreatedData

一个接口,用于描述通过调用 documentCreated.toJSON()返回的数据。

Word.Interfaces.DocumentCreatedLoadOptions

DocumentCreated 对象是由 Application.CreateDocument 创建的顶级对象。 DocumentCreated 对象是一个特殊的 Document 对象。

Word.Interfaces.DocumentCreatedUpdateData

用于更新对象上的 DocumentCreated 数据的接口,用于 在 中使用 documentCreated.set({ ... })

Word.Interfaces.DocumentData

一个接口,用于描述通过调用 document.toJSON()返回的数据。

Word.Interfaces.DocumentLoadOptions

Document 对象是顶层对象。 Document 对象包含一个或多个节、内容控件以及包含文档内容的正文。

Word.Interfaces.DocumentPropertiesData

一个接口,用于描述通过调用 documentProperties.toJSON()返回的数据。

Word.Interfaces.DocumentPropertiesLoadOptions

表示文档属性。

Word.Interfaces.DocumentPropertiesUpdateData

用于更新对象上的 DocumentProperties 数据的接口,用于 在 中使用 documentProperties.set({ ... })

Word.Interfaces.DocumentUpdateData

用于更新对象上的 Document 数据的接口,用于 在 中使用 document.set({ ... })

Word.Interfaces.FieldCollectionData

一个接口,用于描述通过调用 fieldCollection.toJSON()返回的数据。

Word.Interfaces.FieldCollectionLoadOptions

包含 Word.Field 对象的集合。

Word.Interfaces.FieldCollectionUpdateData

用于更新对象上的 FieldCollection 数据的接口,用于 在 中使用 fieldCollection.set({ ... })

Word.Interfaces.FieldData

一个接口,用于描述通过调用 field.toJSON()返回的数据。

Word.Interfaces.FieldLoadOptions

表示一个字段。

Word.Interfaces.FieldUpdateData

用于更新对象上的 Field 数据的接口,用于 在 中使用 field.set({ ... })

Word.Interfaces.FontData

一个接口,用于描述通过调用 font.toJSON()返回的数据。

Word.Interfaces.FontLoadOptions

表示字体。

Word.Interfaces.FontUpdateData

用于更新对象上的 Font 数据的接口,用于 在 中使用 font.set({ ... })

Word.Interfaces.InlinePictureCollectionData

一个接口,用于描述通过调用 inlinePictureCollection.toJSON()返回的数据。

Word.Interfaces.InlinePictureCollectionLoadOptions

包含 Word.InlinePicture 对象的集合。

Word.Interfaces.InlinePictureCollectionUpdateData

用于更新对象上的 InlinePictureCollection 数据的接口,用于 在 中使用 inlinePictureCollection.set({ ... })

Word.Interfaces.InlinePictureData

一个接口,用于描述通过调用 inlinePicture.toJSON()返回的数据。

Word.Interfaces.InlinePictureLoadOptions

表示嵌入式图片。

Word.Interfaces.InlinePictureUpdateData

用于更新对象上的 InlinePicture 数据的接口,用于 在 中使用 inlinePicture.set({ ... })

Word.Interfaces.ListCollectionData

一个接口,用于描述通过调用 listCollection.toJSON()返回的数据。

Word.Interfaces.ListCollectionLoadOptions

包含 Word.List 对象的集合。

Word.Interfaces.ListCollectionUpdateData

用于更新对象上的 ListCollection 数据的接口,用于 在 中使用 listCollection.set({ ... })

Word.Interfaces.ListData

一个接口,用于描述通过调用 list.toJSON()返回的数据。

Word.Interfaces.ListItemData

一个接口,用于描述通过调用 listItem.toJSON()返回的数据。

Word.Interfaces.ListItemLoadOptions

表示段落列表项格式。

Word.Interfaces.ListItemUpdateData

用于更新对象上的 ListItem 数据的接口,用于 在 中使用 listItem.set({ ... })

Word.Interfaces.ListLoadOptions

包含 Word.Paragraph 对象的集合。

Word.Interfaces.NoteItemCollectionData

一个接口,用于描述通过调用 noteItemCollection.toJSON()返回的数据。

Word.Interfaces.NoteItemCollectionUpdateData

用于更新对象上的 NoteItemCollection 数据的接口,用于 在 中使用 noteItemCollection.set({ ... })

Word.Interfaces.NoteItemData

一个接口,用于描述通过调用 noteItem.toJSON()返回的数据。

Word.Interfaces.NoteItemUpdateData

用于更新对象上的 NoteItem 数据的接口,用于 在 中使用 noteItem.set({ ... })

Word.Interfaces.ParagraphCollectionData

一个接口,用于描述通过调用 paragraphCollection.toJSON()返回的数据。

Word.Interfaces.ParagraphCollectionLoadOptions

包含 Word.Paragraph 对象的集合。

Word.Interfaces.ParagraphCollectionUpdateData

用于更新对象上的 ParagraphCollection 数据的接口,用于 在 中使用 paragraphCollection.set({ ... })

Word.Interfaces.ParagraphData

一个接口,用于描述通过调用 paragraph.toJSON()返回的数据。

Word.Interfaces.ParagraphFormatData

一个接口,用于描述通过调用 paragraphFormat.toJSON()返回的数据。

Word.Interfaces.ParagraphFormatUpdateData

用于更新对象上的 ParagraphFormat 数据的接口,用于 在 中使用 paragraphFormat.set({ ... })

Word.Interfaces.ParagraphLoadOptions

表示选定内容、区域、内容控件或文档正文中的单个段落。

Word.Interfaces.ParagraphUpdateData

用于更新对象上的 Paragraph 数据的接口,用于 在 中使用 paragraph.set({ ... })

Word.Interfaces.RangeCollectionData

一个接口,用于描述通过调用 rangeCollection.toJSON()返回的数据。

Word.Interfaces.RangeCollectionLoadOptions

包含 Word.Range 对象的集合。

Word.Interfaces.RangeCollectionUpdateData

用于更新对象上的 RangeCollection 数据的接口,用于 在 中使用 rangeCollection.set({ ... })

Word.Interfaces.RangeData

一个接口,用于描述通过调用 range.toJSON()返回的数据。

Word.Interfaces.RangeLoadOptions

表示文档中的一个连续区域。

Word.Interfaces.RangeUpdateData

用于更新对象上的 Range 数据的接口,用于 在 中使用 range.set({ ... })

Word.Interfaces.SearchOptionsData

一个接口,用于描述通过调用 searchOptions.toJSON()返回的数据。

Word.Interfaces.SearchOptionsLoadOptions

指定要包括在搜索操作中的选项。 若要详细了解如何在 Word JavaScript API 中使用搜索选项,请阅读 使用搜索选项在 Word 加载项中查找文本。

Word.Interfaces.SearchOptionsUpdateData

用于更新对象上的 SearchOptions 数据的接口,用于 在 中使用 searchOptions.set({ ... })

Word.Interfaces.SectionCollectionData

一个接口,用于描述通过调用 sectionCollection.toJSON()返回的数据。

Word.Interfaces.SectionCollectionLoadOptions

包含文档的 Word.Section 对象的集合。

Word.Interfaces.SectionCollectionUpdateData

用于更新对象上的 SectionCollection 数据的接口,用于 在 中使用 sectionCollection.set({ ... })

Word.Interfaces.SectionData

一个接口,用于描述通过调用 section.toJSON()返回的数据。

Word.Interfaces.SectionLoadOptions

表示 Word 文档中的一节。

Word.Interfaces.SectionUpdateData

用于更新对象上的 Section 数据的接口,用于 在 中使用 section.set({ ... })

Word.Interfaces.SettingCollectionData

一个接口,用于描述通过调用 settingCollection.toJSON()返回的数据。

Word.Interfaces.SettingCollectionLoadOptions

包含 Word.Setting 对象的集合。

Word.Interfaces.SettingCollectionUpdateData

用于更新对象上的 SettingCollection 数据的接口,用于 在 中使用 settingCollection.set({ ... })

Word.Interfaces.SettingData

一个接口,用于描述通过调用 setting.toJSON()返回的数据。

Word.Interfaces.SettingLoadOptions

表示加载项的设置。

Word.Interfaces.SettingUpdateData

用于更新对象上的 Setting 数据的接口,用于 在 中使用 setting.set({ ... })

Word.Interfaces.ShadingData

一个接口,用于描述通过调用 shading.toJSON()返回的数据。

Word.Interfaces.ShadingUpdateData

用于更新对象上的 Shading 数据的接口,用于 在 中使用 shading.set({ ... })

Word.Interfaces.StyleCollectionData

一个接口,用于描述通过调用 styleCollection.toJSON()返回的数据。

Word.Interfaces.StyleCollectionUpdateData

用于更新对象上的 StyleCollection 数据的接口,用于 在 中使用 styleCollection.set({ ... })

Word.Interfaces.StyleData

一个接口,用于描述通过调用 style.toJSON()返回的数据。

Word.Interfaces.StyleLoadOptions

表示 Word 文档中的样式。

Word.Interfaces.StyleUpdateData

用于更新对象上的 Style 数据的接口,用于 在 中使用 style.set({ ... })

Word.Interfaces.TableBorderData

一个接口,用于描述通过调用 tableBorder.toJSON()返回的数据。

Word.Interfaces.TableBorderLoadOptions

指定边框样式。

Word.Interfaces.TableBorderUpdateData

用于更新对象上的 TableBorder 数据的接口,用于 在 中使用 tableBorder.set({ ... })

Word.Interfaces.TableCellCollectionData

一个接口,用于描述通过调用 tableCellCollection.toJSON()返回的数据。

Word.Interfaces.TableCellCollectionLoadOptions

包含文档的 TableCell 对象的集合。

Word.Interfaces.TableCellCollectionUpdateData

用于更新对象上的 TableCellCollection 数据的接口,用于 在 中使用 tableCellCollection.set({ ... })

Word.Interfaces.TableCellData

一个接口,用于描述通过调用 tableCell.toJSON()返回的数据。

Word.Interfaces.TableCellLoadOptions

表示 Word 文档中的表格单元格。

Word.Interfaces.TableCellUpdateData

用于更新对象上的 TableCell 数据的接口,用于 在 中使用 tableCell.set({ ... })

Word.Interfaces.TableCollectionData

一个接口,用于描述通过调用 tableCollection.toJSON()返回的数据。

Word.Interfaces.TableCollectionLoadOptions

包含文档的 Table 对象的集合。

Word.Interfaces.TableCollectionUpdateData

用于更新对象上的 TableCollection 数据的接口,用于 在 中使用 tableCollection.set({ ... })

Word.Interfaces.TableData

一个接口,用于描述通过调用 table.toJSON()返回的数据。

Word.Interfaces.TableLoadOptions

表示 Word 文档中的表。

Word.Interfaces.TableRowCollectionData

一个接口,用于描述通过调用 tableRowCollection.toJSON()返回的数据。

Word.Interfaces.TableRowCollectionLoadOptions

包含文档的 TableRow 对象的集合。

Word.Interfaces.TableRowCollectionUpdateData

用于更新对象上的 TableRowCollection 数据的接口,用于 在 中使用 tableRowCollection.set({ ... })

Word.Interfaces.TableRowData

一个接口,用于描述通过调用 tableRow.toJSON()返回的数据。

Word.Interfaces.TableRowLoadOptions

表示 Word 文档中的一行。

Word.Interfaces.TableRowUpdateData

用于更新对象上的 TableRow 数据的接口,用于 在 中使用 tableRow.set({ ... })

Word.Interfaces.TableStyleData

一个接口,用于描述通过调用 tableStyle.toJSON()返回的数据。

Word.Interfaces.TableStyleUpdateData

用于更新对象上的 TableStyle 数据的接口,用于 在 中使用 tableStyle.set({ ... })

Word.Interfaces.TableUpdateData

用于更新对象上的 Table 数据的接口,用于 在 中使用 table.set({ ... })

Word.Interfaces.TrackedChangeCollectionData

一个接口,用于描述通过调用 trackedChangeCollection.toJSON()返回的数据。

Word.Interfaces.TrackedChangeCollectionUpdateData

用于更新对象上的 TrackedChangeCollection 数据的接口,用于 在 中使用 trackedChangeCollection.set({ ... })

Word.Interfaces.TrackedChangeData

一个接口,用于描述通过调用 trackedChange.toJSON()返回的数据。

枚举

Word.Alignment
Word.BodyType
Word.BorderLocation
Word.BorderType
Word.BreakType

指定分页符的窗体。

Word.BuiltInStyleName

表示 Word 文档中的内置样式。

Word.CellPaddingLocation
Word.ChangeTrackingMode

ChangeTracking 模式。

Word.ChangeTrackingVersion

指定文本的当前版本或原始版本。

Word.ContentControlAppearance

ContentControl 外观。

Word.ContentControlType

指定支持的内容控件类型和子类型。

Word.DocumentPropertyType
Word.ErrorCodes
Word.HeaderFooterType
Word.InsertLocation

插入位置类型。

Word.ListBullet
Word.ListLevelType
Word.ListNumbering
Word.LocationRelation
Word.RangeLocation
Word.SaveBehavior

指定 的 Document.save保存行为。

Word.SelectionMode

此枚举设置文档中光标 (插入点) 在选定内容之后的位置。

Word.UnderlineType

支持下划线格式的样式。

Word.VerticalAlignment

函数

Word.run(objects, batch)

使用以前创建的 API 对象的 RequestContext 执行对 Word 对象模型执行操作的批处理脚本。

Word.run(object, batch)

使用以前创建的 API 对象的 RequestContext 执行对 Word 对象模型执行操作的批处理脚本。 承诺解决后,将释放在执行过程中自动分配的任何跟踪对象。

Word.run(batch)

使用新的 RequestContext 执行对 Word 对象模型执行操作的批处理脚本。 承诺解决后,将释放在执行过程中自动分配的任何跟踪对象。

函数详细信息

Word.run(objects, batch)

使用以前创建的 API 对象的 RequestContext 执行对 Word 对象模型执行操作的批处理脚本。

export function run<T>(objects: OfficeExtension.ClientObject[], batch: (context: Word.RequestContext) => Promise<T>): Promise<T>;

参数

objects

OfficeExtension.ClientObject[]

以前创建的 API 对象的数组。 将对数组进行验证,以确保所有对象共享相同的上下文。 批处理将使用此共享的 RequestContext,这意味着“context.sync () ”将选取应用于这些对象的任何更改。

batch

(context: Word.RequestContext) => Promise<T>

一个函数,它接受 RequestContext 并返回承诺 (通常只是“context.sync () ”) 的结果。 上下文参数有助于向 Word 应用程序发出请求。 由于 Office 加载项和 Word 应用程序在两个不同的进程中运行,因此需要 RequestContext 才能从外接程序访问 Word 对象模型。

返回

Promise<T>

Word.run(object, batch)

使用以前创建的 API 对象的 RequestContext 执行对 Word 对象模型执行操作的批处理脚本。 承诺解决后,将释放在执行过程中自动分配的任何跟踪对象。

export function run<T>(object: OfficeExtension.ClientObject, batch: (context: Word.RequestContext) => Promise<T>): Promise<T>;

参数

object
OfficeExtension.ClientObject

以前创建的 API 对象。 批处理将使用与传入对象相同的 RequestContext,这意味着“context.sync () ”将选取应用于该对象的任何更改。

batch

(context: Word.RequestContext) => Promise<T>

一个函数,它接受 RequestContext 并返回承诺 (通常只是“context.sync () ”) 的结果。 上下文参数有助于向 Word 应用程序发出请求。 由于 Office 加载项和 Word 应用程序在两个不同的进程中运行,因此需要 RequestContext 才能从外接程序访问 Word 对象模型。

返回

Promise<T>

Word.run(batch)

使用新的 RequestContext 执行对 Word 对象模型执行操作的批处理脚本。 承诺解决后,将释放在执行过程中自动分配的任何跟踪对象。

export function run<T>(batch: (context: Word.RequestContext) => Promise<T>): Promise<T>;

参数

batch

(context: Word.RequestContext) => Promise<T>

一个函数,它接受 RequestContext 并返回承诺 (通常只是“context.sync () ”) 的结果。 上下文参数有助于向 Word 应用程序发出请求。 由于 Office 加载项和 Word 应用程序在两个不同的进程中运行,因此需要 RequestContext 才能从外接程序访问 Word 对象模型。

返回

Promise<T>