This topic describes how to obtain the revision objects, accept all revisions, and obtain the revision time of a single revision object when you use a text document.
Obtain revision objects
Obtain the specified revision objects.
Syntax
Expression.ActiveDocument.RevisionsExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; }
Switch between the edit mode and the revision mode
Switch between the edit mode and the revision mode.
Syntax
Expression.ActiveDocument.TrackRevisions = BooleanExpression: the document type application object.
A value of the
booleantype is returned.trueindicates that the revision mode is used.falseindicates that the edit mode is used.Example
async function example() { await instance.ready(); const app = instance.Application; // Switch the current document to the revision mode. app.ActiveDocument.TrackRevisions = true; }
Obtain the full-text revisions
Obtain the full-text revisions.
Syntax
Expression.ActiveDocument.Revisions.Json()Expression: the document type application object.
Return value
Full-text revisions are returned in the
Array.<Object>format, such as[{ user, ... }]. The following table describes the returned parameters.Parameter
Data type
Description
user
String
The username.
leader
String
The revision comments.
begin
String
The start position of the revision.
end
String
The end position of the revision.
content
String
The revised content.
type
String
The revision type.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Obtain the full-text revisions. const revisionData = await revisions.Json(); console.log(revisionData); }
Obtain the number of full-text revisions
Obtain the number of full-text revisions.
Syntax
Expression.ActiveDocument.Revisions.CountExpression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Obtain the number of full-text revisions. const count = await revisions.Count; console.log(count); }
Accept all revisions
Accept all revisions to the document.
Syntax
Expression.ActiveDocument.Revisions.AcceptAll()Expression: the document type application object.
Example
async function example() { await instance.ready(); const app = instance.Application; // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Accept all revisions to the document. await revisions.AcceptAll(); }
Reject all revisions
Reject all revisions to the document.
Syntax
Expression.ActiveDocument.Revisions.RejectAll()Expression: the document type application object.
Example
async function example() { await instance.ready(); // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Reject all revisions to the document await revisions.RejectAll(); }
Single revision
Obtain a single revision object
Syntax
Expression.ActiveDocument.Revisions.Item(Index)Expression: the document type application object.
Example
async function example() { await instance.ready(); // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Obtain a single revision object. const revision = await revisions.Item(1); }
Obtain the revision time
Syntax
Expression.ActiveDocument.Revisions.Item(Index).DateExpression: the document type application object.
Example
async function example() { await instance.ready(); // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Obtain a single revision object. const revision = await revisions.Item(1); // Obtain the revision time. const date = await revision.Date; console.log(date); }
Obtain the author of a revision
Syntax
Expression.ActiveDocument.Revisions.Item(Index).AuthorExpression: the document type application object.
Example
async function example() { await instance.ready(); // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Obtain a single revision object. const revision = await revisions.Item(1); // Obtain the author of the revision. const author = await revision.Author; console.log(author); }
Obtain the revision type
Syntax
Expression.ActiveDocument.Revisions.Item(Index).TypeExpression: the document type application object.
Return value
Returns
WdRevisionTypeinEnumthat represents the corresponding revision type.Parameter
Parameter description
Data type
Usage method
Field (Column name)
Value
Value description
WdRevisionType
The type of a change that is labeled with a revision mark.
Enum
Expression.Enum.WdRevisionType.wdNoRevisionExpression: the document type application object.
wdNoRevision
0
No modification.
wdRevisionInsert
1
Detetion.
wdRevisionDelete
2
Insertion.
wdRevisionProperty
3
The parameter is changed.
wdRevisionStyle
8
The style is changed.
Example
async function example() { await instance.ready(); // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Obtain a single revision object. const revision = await revisions.Item(1); // Obtain the revision type. const type = await revision.Type; console.log(type); }
Obtain the range of a revision
Syntax
Expression.ActiveDocument.Revisions.Item(Index).RangeExpression: the document type application object.
Example
async function example() { await instance.ready(); // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Obtain a single revision object. const revision = await revisions.Item(1); // Obtain the range of the revision. const range = await revision.Range; console.log(range); }Obtain the ID of a revision user
Syntax
Expression.ActiveDocument.Revisions.Item(Index).userIDExpression: the document type application object.
Example
async function example() { await instance.ready(); // Obtain the revision objects. const revisions = await app.ActiveDocument.Revisions; // Obtain a single revision object. const revision = await revisions.Item(1); // Obtain the ID of the revision user. const userID = await revision.userID; console.log(userID); }