AW: Speicheraufforderung nach Aktivierung aktiver Inhalte
StefanoFereri
Hi Onur,
ich dachte, der Rest ist nicht wichtig, weil ja eh ein Saved=True am Ende steht. Aber hier ist er:
Private Sub Workbook_Open()
Dim Delim As Integer, ReNr As Integer, LetzteReNr As Integer, StartAktion As Integer
Dim File As String, LocPath As String
ActiveWindow.DisplayHeadings = True
ActiveWindow.DisplayGridlines = True
Application.DisplayFormulaBar = True
ActiveWindow.ScrollRow = 1
Application.ScreenUpdating = False
Sheets("Rechnung").Protect Password:="", UserInterFaceOnly:=True
Sheets("Vorgaben").Protect Password:="", UserInterFaceOnly:=True
Sheets("Adressaten").Protect Password:="", UserInterFaceOnly:=True
Sheets("Rechnung").EnableSelection = xlUnlockedCells
Sheets("Vorgaben").EnableSelection = xlUnlockedCells
ActiveWorkbook.AutoSaveOn = False
Cells(23, 13).Value = ThisWorkbook.Path & "\"
LocPath = Cells(23, 13).Value
If InStr(1, LocPath, "my.sharepoint.com") <> 0 Or InStr(1, LocPath, "d.docs.live.net") <> 0 Then
LocPath = OneDriveLocalFilePath() & "\"
Cells(23, 13).Value = LocPath
End If
Sheets("Rechnung").Select
SpeichernMitButton = 0
If Not Left(ThisWorkbook.Name, 11) = "Rechnung_Nr" Then '...dann ist es eine neue Rechnung
Cells(5, 13).Value = Format(Date, "D. MMMM YYYY")
File = Dir(LocPath & "Rechnung_Nr*.xlsm")
If File = "" Then
MsgBox "Finde keine Rechnungen. Ich gehe davon aus," & Chr(10) & "dass dies die erste Rechnung wird."
Cells(4, 13).Value = 1
Else
ReNr = 1
LetzteReNr = 1
Do Until File = ""
Delim = InStr(13, File, "_")
LetzteReNr = CInt(Mid(File, 13, Delim - 13))
If LetzteReNr > ReNr Then ReNr = LetzteReNr
File = Dir()
Loop
Cells(4, 13).Value = ReNr + 1
End If
End If
Cells(Cells(2, 13).Value, 3).Select
Application.ScreenUpdating = True
Application.OnKey "~", "EnterTaste"
Application.OnKey "{Enter}", "EnterTaste"
ThisWorkbook.Saved = True
MsgBox ThisWorkbook.VBProject.Name
End Sub
Die MsgBox habe ich jetzt auch in BeforeClose eingebaut, dort zeigt sie "False", sobald ich die Datei nach einer Umbenennung öffne und ohne weitere Änderung wieder schließe. Das Workbook_SheetChange-Ereignis kannte ich noch gar nicht, werde ich gleich morgen ebenfalls testen. Besten Dank erstmal!