Class CoAuthLock (Word VBA)

The class CoAuthLock represents a lock within the document. The CoAuthLock object is a member of the CoAuthLocks collection. To use a CoAuthLock class variable it first needs to be instantiated, for example


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

For Each

Here is an example of processing the CoAuthLock items in a collection.


Dim cal As CoAuthLock 
For Each cal In ActiveDocument.CoAuthoring.Locks 
    If cal.Type = wdLockReservation Then cal.Unlock 
Next cal

HeaderFooter

This object or member has been deprecated. You should not use it in new applications.


Dim booHeaderFooter As Boolean
booHeaderFooter = ActiveDocument.Range.Locks(1).HeaderFooter

Owner


Dim carOwner As CoAuthor
Set carOwner = ActiveDocument.Range.Locks(1).Owner

Range

Returns a Range object that represents the portion of a document that is contained in the specified object.


MsgBox ActiveDocument.Coauthoring.Locks(1).Range

Type

Returns a WdLockType constant that specifies the lock type. Possible return 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.


Dim myLock As CoAuthLock 
 
For Each myLock In ActiveDocument.CoAuthoring.Locks 
    If myLock.Type = wdLockReservation Then 
        myLock.Unlock 
    End If 
Next myLock

Unlock

Unlocks the specified lock.

The Unlock method unlocks the specified lock even if it belongs to another user other than the current user.


Dim myLock as CoAuthLock 
 
For Each myLock In ActiveDocument.CoAuthoring.Locks 
   myLock.Unlock     
Next myLock