Locked Property

Microsoft Word Visual Basic

Subdocument object: True if a subdocument in a master document is locked.

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.

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.

expression.Locked

expression    Required. An expression that returns one of the above objects.

ShowLocked property as it applies to the 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.

expression.Locked

expression    Required. An expression that returns a Fields object.

Example

ShowAs it applies to the Subdocument object.

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
				

ShowAs it applies to the Fields object.

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