PW = InputBox("Vergeben Sie nun ein Passwort", "Abschluss")
wsFormular.Protect PW
ThisWorkbook.Protect PW
ActiveWorkbook.Save
An dieser Stelle wird mir PW in der Überwachung als Leer angezeigt.Application.EnableEvents = False
ThisWorkbook.Unprotect PW
With Tabelle93
.Unprotect PW
.Range("C2").Value = strAnbieterName
.Protect PW
End With
ThisWorkbook.Protect PW
Application.EnableEvents = True
Ich bekomme gemeldet, daß das PW falsch sei. Warum ist es denn nicht verfügbar? Wenn ich die Datei entsperre, muß ich es doch auch eingeben, und es wird akzeptiert?in einem globalen Modul:
Public strAnbieterName As Variant 'zu Namenseingabe der Anbieter in DieseArbeitsmappe
Aufruf im Blatt ToDo:
Private Sub CmBtFormularVersenden_Click()
Me.CmBtFormularVersenden.Enabled = False
modAusschreibgEinrichten.ToDo_Formular_versandfertig
Me.CmBtFormularVersenden.Enabled = True
im Modul AusschreibungEinrichten:
Public PW As String
Dim wsFormular As Worksheet
Option Explicit
Public Sub ToDo_Formular_versandfertig()
Set wsFormular = ThisWorkbook.Worksheets("Formular")
PW = InputBox("Vergeben Sie nun ein Passwort", "Abschluss")
wsFormular.Protect Password:=PW, UserInterfaceOnly:=True
ThisWorkbook.Protect Password:=PW, UserInterfaceOnly:=True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
With ActiveWorkbook
.Names.Add Name:="Ausschreibung.Projekt", RefersTo:="=""" & ProjName & """"
.Names.Add Name:="Ausschreibung.TP", RefersTo:="=""" & TPName & """"
.Names.Add Name:="Ausschreibung.Anbieter", RefersTo:="=""" & strAnbieterName & """"
End With
End Sub
in DieseArbeitsmappe:
Private Sub Workbook_Open()
'Informationen aus Namen und Vorversionen einlesen
ProjName = ThisWorkbook.Names("Ausschreibung.Projekt").Value
ProjName = Mid(ProjName, 3, Len(ProjName) - 3)
TPName = ThisWorkbook.Names("Ausschreibung.TP").Value
TPName = Mid(TPName, 3, Len(TPName) - 3)
strAnbieterName = ThisWorkbook.Worksheets("Formular").Range("C2").Value
If ThisWorkbook.Worksheets("Formular").Range("C2").Value <> "" Then
MsgBox "Name schon drin"
GoTo hier
Else 'Input "...bitte Name in Kurzform..."
strAnbieterName = Application.InputBox(Tabelle93.Range("sprNameKurzf").Value, Tabelle93.Range( _
"sprRegistr").Value)
End If
ThisWorkbook.Unprotect Password:=PW
With Tabelle93
.Unprotect Password:=PW
.Range("C2").Value = strAnbieterName
.Protect Password:=PW
End With
ThisWorkbook.Protect Password:=PW
End Sub
PW = InputBox("Vergeben Sie nun ein Passwort", "Abschluss")
wsFormular.Protect Password:=PW, UserInterfaceOnly:=True
ThisWorkbook.Protect Password:=PW, UserInterfaceOnly:=True
Reklamiert wurde DAS ZWEITE UserInterfaceOnly, also das bei ThisWorkbook.
ThisWorkbook.Unprotect Password:=PW
With Tabelle93
.Unprotect Password:=PW
.Range("C2").Value = strAnbieterName
.Protect Password:=PW
End With
ThisWorkbook.Protect Password:=PW
die Zeile .Unprotect Password:=PW angemeckert, und zwar mit "ungültiges Passwort"PW = InputBox("Vergeben Sie nun ein Passwort", "Abschluss")
wsFormular.Protect Password:=PW, UserInterfaceOnly:=True
ThisWorkbook.Protect Password:=PW
With ActiveWorkbook
.Names.Add Name:="Ausschreibung.Projekt", RefersTo:="=""" & ProjName & """"
.Names.Add Name:="Ausschreibung.TP", RefersTo:="=""" & TPName & """"
.Names.Add Name:="Ausschreibung.Anbieter", RefersTo:="=""" & strAnbieterName & """"
.Names.Add Name:="Ausschreibung.PW", RefersTo:="=""" & PW & """"
End With
hab ich damit das PW "bewahrt"?ThisWorkbook.Unprotect Password:=PW
With Tabelle93
.Unprotect Password:=PW
.Range("C2").Value = strAnbieterName
.Protect Password:=PW
End With
ThisWorkbook.Protect Password:=PW
Grüße - Jörg