Hallo Forum,
im web habe ich englischsprachigen Code gefunden, der das Ereignis abfängt, dass das Blatt „entschützt“ wird. Diesen wollte ich so anpassen, dass dann immer automatisch die ursprüngliche Sortierung hergestellt wird, wenn ich die Formeln ändern will, weil das sonst nicht passt.
Das Problem ist aber, dass der Code gar nicht erst gestartet wird
Ich glaube ja, dass es hier ein Übersetzungsproblem gibt, dass also der Code in einem englischen Umfeld laufen würde und ich nur ein paar Abfragen ändern müsste …
Vielleicht weiß ja Jemand, was und wie ( ? ).
Freundliche Grüße
Thomas
In einem Standardmodul soll stehen:
Public Sub Custom_Protect()
On Error Resume Next
With CommandBars.ActionControl
If Not ActiveSheet.ProtectContents Then
Application.Dialogs(xlDialogProtectDocument).Show
ActiveSheet.Protect
.Caption = „Un&:stuck_out_tongue_winking_eye:rotect Sheet…“
ElseIf ActiveSheet.ProtectContents Then
ActiveSheet.Unprotect
If Err.Number 0 Then
MsgBox „Wrong Password ! - Try again“, vbCritical, „Unprotecting Sheet“
Err.Clear
Exit Sub
End If
If Not ActiveSheet.ProtectContents Then
.Caption = „&:stuck_out_tongue_winking_eye:rotect Sheet…“
MsgBox „You have unprotected the Sheet !“ & vbCr & _
„Be careful you don’t mess up the sheet layout !“, vbExclamation
End If
End If
End With
End Sub
Im code des zu überwachenden Blattes:
Private Sub Worksheet_Activate()
'Change Built-In protection functionality
On Error Resume Next
With Application.CommandBars(1).Controls(„Tools“).Controls(„Protection“)
.Controls(„UnProtect Sheet…“).OnAction = „Custom_Protect“
.Controls(„Protect Sheet…“).OnAction = „Custom_Protect“
End With
End Sub
Private Sub Worksheet_Deactivate()
’ Restore Built-in functionality for other sheets.
On Error Resume Next
With Application.CommandBars(1).Controls(„Tools“).Controls(„Protection“)
.Controls(„UnProtect Sheet…“).Reset
.Controls(„Protect Sheet…“).Reset
End With
End Sub