Hi,
I tested a code in a file that disabled sheet delete and rename.
Now in every Excel file I create or open I can't rename any sheet, if I try Excel tries to open the initial file that had the code and tries to run a module procedure.
The code was:
In a sheet:
Private Sub Worksheet_Activate()
For Each SHT_OPTIONS In Application.CommandBars
Set SHT_DELETE = SHT_OPTIONS.FindControl(ID:=847, recursive:=True)
Set SHT_RENAME = SHT_OPTIONS.FindControl(ID:=889, recursive:=True)
If Not SHT_DELETE Is Nothing Then
SHT_DELETE.OnAction = "PUB_SHEET_DISABLE"
SHT_DELETE.State = msoButtonUp
ElseIf Not SHT_RENAME Is Nothing Then
SHT_RENAME.OnAction = "PUB_SHEET_DISABLE"
SHT_RENAME.State = msoButtonUp
End If
Next SHT_OPTIONS
End Sub
Private Sub Worksheet_Deactivate()
For Each SHT_OPTIONS In Application.CommandBars
Set SHT_DELETE = SHT_OPTIONS.FindControl(ID:=847, recursive:=True)
Set SHT_RENAME = SHT_OPTIONS.FindControl(ID:=889, recursive:=True)
If Not SHT_DELETE Is Nothing Then
SHT_DELETE.OnAction = ""
ElseIf Not SHT_RENAME Is Nothing Then
SHT_RENAME.OnAction = ""
End If
Next SHT_OPTIONS
End Sub
In a module:
Public SHT_OPTIONS As CommandBar
Public SHT_RENAME As CommandBarControl
Public SHT_DELETE As CommandBarControl
Public Sub PUB_SHEET_DISABLE()
MsgBox "Option disabled !", vbOKOnly + vbExclamation, "Warning"
End Sub
Any idea how to get rid of this?
Thank you in advance!
Bookmarks