marreco
03-23-2013, 02:20 PM
Hi.
1. Prevent a specific plan was not possible to exclude (Sheet1)
2. Prevent File no plan could be excluded, but that could be added further.
I tried it but failed.
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim sht As Worksheet: Set sht = Sh
If sht.Name = "Plan1" Then
SetDeleteOption (False)
End If
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Dim sht As Worksheet: Set sht = Sh
If sht.Name = "Plan1" Then
SetDeleteOption (True)
End If
End Sub
Private Sub SetDeleteOption(ByVal AllowDelete As Boolean)
Dim CommBarTmp, Commbar As CommandBar
For Each Commbar In Application.CommandBars
Set CommBarTmp = Commbar.FindControl(ID:=847, recursive:=True)
If Not CommBarTmp Is Nothing Then CommBarTmp.Enabled = AllowDelete
Next
End Sub
Thanks
1. Prevent a specific plan was not possible to exclude (Sheet1)
2. Prevent File no plan could be excluded, but that could be added further.
I tried it but failed.
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim sht As Worksheet: Set sht = Sh
If sht.Name = "Plan1" Then
SetDeleteOption (False)
End If
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Dim sht As Worksheet: Set sht = Sh
If sht.Name = "Plan1" Then
SetDeleteOption (True)
End If
End Sub
Private Sub SetDeleteOption(ByVal AllowDelete As Boolean)
Dim CommBarTmp, Commbar As CommandBar
For Each Commbar In Application.CommandBars
Set CommBarTmp = Commbar.FindControl(ID:=847, recursive:=True)
If Not CommBarTmp Is Nothing Then CommBarTmp.Enabled = AllowDelete
Next
End Sub
Thanks