Class CoAuthLocks (Word VBA)

A collection of CoAuthLock objects. To use a CoAuthLocks class variable it first needs to be instantiated, for example


Dim cals as CoAuthLocks
Set cals = ActiveDocument.Range.Locks

Add

Returns a CoAuthLock object that represents a lock added to a specified range.

The following code example adds a reservation lock to the first paragraph in the active document.

Add (Range, Type)


ActiveDocument.CoAuthoring.Locks.Add(ActiveDocument.Paragraphs(1).Range, wdLockReservation)

Arguments

Optional arguments

The following arguments are optional

Range (Range) - Specifies the document range locked by the CoAuthLock object. This parameter may be a Paragraph, Column, Cell, Row, Table, Range, or Selection object.

Type (WdLockType) - Specifies the type of lock. The WdLockType specified can only be wdLockEphemeral or WdLockReservation.


Possible values are

wdLockChanged Specifies a placeholder lock. A placeholder lock indicates that another user has removed their lock from the range, but the current user has not updated their view of the document by saving.
wdLockEphemeral Specifies an ephemeral lock. Word implicitly places an ephemeral lock on a range when a user begins editing a range in a document with coauthoring enabled.
wdLockNone Reserved for future use.
wdLockReservation Specifies a reservation lock. A reservation lock is explicitly created by a user through the Block Authors button on the Review tab in Word.

Count

Returns a Long that represents the number of locks in the CoAuthLocks collection.


MsgBox "The active document contains " & _ 
    ActiveDocument.CoAuthoring.Locks.Count & " locks."

Item

Returns an individual CoAuthLock object in a collection.

Item (Index)

Index: The individual object to be returned.


Dim cal As CoAuthLock
Set cal = ActiveDocument.Range.Locks(Index:=1)

RemoveEphemeralLocks

Removes ephemeral locks from the document.

Ephemeral locks are automatically applied to a range when a co author begins to edit a document that has co authoring enabled.


ActiveDocument.CoAuthoring.Locks.RemoveEphemeralLocks