Enabled Property
True if the specified command bar or command bar control is enabled. Read/write Boolean.
Remarks
For command bars, setting this property to True causes the name of the command bar to appear in the list of available command bars.
For built-in controls, if you set the Enabled property to True, the application determines its state, but setting it to False will force it to be disabled.
Enabled property as it applies to the Permission object.
Returns or sets a Boolean value that indicates whether permissions are enabled on the active document. Read/write Boolean.
expression.Enabled
expression Required. An expression that returns a Permission object.
Remarks
Use the Enabled property to determine whether permissions are restricted on the active document, and to enable or disable permissions. Set Enabled to False to disable permissions and to remove all users, other than the document author, and their permissions.
When permissions are disabled, the Count property of the Permission object returns 0 (zero); however, when permissions are re-enabled, the permissions of the document author remain intact.
Example
This example adjusts the command bars according to the user level specified by user
. If user
is "Level 1," the command bar named "VB Custom Bar" is displayed. If user
is any other value, the built-in Visual Basic command bar is reset to its default state and the command bar named "VB Custom Bar" is disabled.
Set myBar = CommandBars _
.Add(Name:="VB Custom Bar", Position:=msoBarTop, _
Temporary:=True)
With myBar
.Controls.Add Type:=msoControlButton, ID:=2
.Visible = True
End With
If user = "Level 1" Then
myBar.Visible = True
Else
CommandBars("Visual Basic").Reset
myBar.Enabled = False
End If
This example adds two command bar buttons to the command bar named “Custom”. The first control is disabled; the second control is enabled by default.
Set myBar = CommandBars("Custom")
With myBar
.Controls.Add Type:=msoControlButton, Id:=3
.Controls(1).Enabled = False
.Controls.Add Type:=msoControlButton, Id:=3
End With
myBar.Visible = True
As it applies to the Permission object.
The following example checks the Enabled property to determine whether permissions are restricted on the active document.
Dim irmPermission As Office.Permission
Set irmPermission = ActiveWorkbook.Permission
Select Case irmPermission.Enabled
Case True
MsgBox "Permissions are restricted on this document." & vbCrLf & _
"There are " & irmPermission.Count & " users with rights.", _
vbInformation + vbOKOnly, "IRM Information"
Case False
MsgBox "Permissions are NOT restricted on this document.", _
vbInformation + vbOKOnly, "IRM Information"
End Select
Set irmPermission = Nothing