AW: Excelkopierschutz
30.03.2017 13:56:35
ChrisL
Hi Johannes
Wie bereits erwähnt, ist das Vorgehen nicht 100% sicher.
Erstelle eine Mappe mit Tabelle1-3 und einem leeren Blatt "Stopp". Alt+F11, links Doppelklick auf DieseArbeitsmappe, Code einfügen.
Nicht vergessen den Pfad im Code anzupassen, weil sonst kannst du die Mappe selber nicht mehr öffnen. VBA-Passwort setzen, damit niemand das Passwort vom Mappenschutz aus dem Makro erfährt.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim sPW As String
sPW = "Passwort"
On Error Resume Next
Application.ScreenUpdating = False
Application.EnableEvents = False
ThisWorkbook.Unprotect sPW
Call SheetsAusblenden
ThisWorkbook.Protect sPW
Cancel = True
If SaveAsUI Then
Application.Dialogs(xlDialogSaveAs).Show
Else
ThisWorkbook.Save
End If
Application.EnableEvents = True
ThisWorkbook.Unprotect sPW
Call SheetsEinblenden
ThisWorkbook.Protect sPW
ThisWorkbook.Saved = True
Application.EnableEvents = True
End Sub
Private Sub Workbook_Open()
Dim sPW As String
sPW = "Passwort"
If ThisWorkbook.FullName = "C:\Pfad\Mappe1.xlsm" Then 'hier anpassen!!!!!!!!!!!
ThisWorkbook.Unprotect sPW
Call SheetsEinblenden
ThisWorkbook.Protect sPW
ThisWorkbook.Saved = True
Else
ThisWorkbook.Close
End If
End Sub
Private Sub SheetsAusblenden()
With ThisWorkbook
.Sheets("Stopp").Visible = True
.Sheets("Tabelle1").Visible = xlVeryHidden
.Sheets("Tabelle2").Visible = xlVeryHidden
.Sheets("Tabelle3").Visible = xlVeryHidden
End With
End Sub
Private Sub SheetsEinblenden()
With ThisWorkbook
.Sheets("Tabelle1").Visible = True
.Sheets("Tabelle2").Visible = True
.Sheets("Tabelle3").Visible = True
.Sheets("Stopp").Visible = xlVeryHidden
End With
End Sub
Das Prinzip:
- Blatt "Stopp" ist ein leeres Blatt, welches vor jedem Speichern eingeblendet wird. Alle anderen Blätter werden vor dem Speichern ausgeblendet.
- Tabelle1-3 enthält die Daten, welche nur sichtbar sind, wenn Makros aktiviert werden. Ansonsten ist Blatt "Stopp" sichtbar.
cu
Chris