Locked Property

Applies To

Field object, Fields collection object, LinkFormat object, MailMergeField object, Subdocument object.

Description

Subdocument object: True if a subdocument in a master document is locked. Read/write Boolean.

LinkFormat object: True if a Field, InlineShape, or Shape object is locked to prevent automatic updating. If you use this property with a Shape object that's a floating linked picture (a picture added with the AddPicture method of the Shapes object), an error occurs. Read/write Boolean.

Field or MailMergeField object: True if the specified field is locked. When a field is locked, you cannot update the field results. Read/write Boolean.

Fields object: True if all fields in the Fields collection are locked. Can be True, False, or wdUndefined (if some of the fields in the collection are locked). Read/write Long.

See Also

Fields property, Unlink method, Update method.

Example

This example checks the first subdocument in the specified master document and sets the master document to allow only comments if the subdocument is locked.

If ActiveDocument.Subdocuments(1).Locked = True Then
    ActiveDocument.Protect Type:=wdAllowOnlyComments
End If
This example inserts a DATE field at the beginning of the selection and then locks the field.

Selection.Collapse Direction:=wdCollapseStart
Set myField = ActiveDocument.Fields.Add(Range:=Selection.Range, _
    Type:=wdFieldDate)
myField.Locked = True
This example locks all the fields in the selection.

Selection.Fields.Locked = True
This example displays a message if some of the fields in the active document are locked.

Set theFields = ActiveDocument.Fields
If theFields.Locked = wdUndefined Then
    MsgBox "Some fields are locked"
ElseIf theFields.Locked = False Then
    MsgBox "No fields are locked"
ElseIf theFields.Locked = True Then
    MsgBox "All fields are locked"
End If