RemoveAll Method

Microsoft Office Visual Basic

RemoveAll Method

Removes all UserPermission objects from the Permission collection of the active document.

expression.RemoveAll()

expression    Required. An expression that returns a Permission object.

Remarks

The RemoveAll method removes all UserPermissions that have been added to the Permission collection and disables restrictions on the active document. After calling the RemoveAll method, the Enabled property of the Permission object returns False and the Count property returns 0 (zero).

Example

The following example uses the RemoveAll method to remove all user permissions and to disable restrictions on the active document.

        Dim irmPermission As Office.Permission
    Set irmPermission = ActiveWorkbook.Permission
    If irmPermission.Enabled Then
        irmPermission.RemoveAll
        MsgBox "All permissions removed." & vbCrLf & _
            "Count: " & irmPermission.Count & vbCrLf & _
            "Enabled: " & irmPermission.Enabled, _
            vbInformation + vbOKOnly, "IRM Information"
    Else
        MsgBox "This document is not restricted.", _
            vbInformation + vbOKOnly, "IRM Information"
    End If
    Set irmPermission = Nothing