AW: Beim Speichern Sicherungskopie erstellen?
08.10.2008 12:49:53
Larsinator
Hallo Matthias,
gegen konkrete Hilfe will ich mich nicht wehren. ;-)) Unten meinen ganzen aktuellen Stand.
Ich hatte bis jetzt drei Ansätze ergoogelt und getestet, die ersten beiden sind auskommentiert...
Danke nochmal
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim PathDestination As String, FileDestination As String, FileSource As String
Dim FileExist As Boolean, bln As Boolean, IsCopySaved As Boolean
FileSource = "D:\" & ActiveWorkbook.Name
PathDestination = "D:\test\"
FileDestination = PathDestination & "Kopie.xls"
If (FileDestination = "" Or FileSource = "") Then GoTo ENDE 'Datei wird trotzdem _
gespeichert!
FileExist = Dir$(FileSource) ""
If (FileExist = False) Then GoTo ENDE 'Datei wird trotzdem gespeichert!
FileExist = Dir$(PathDestination) ""
If (FileExist = False) Then GoTo ENDE 'Datei wird trotzdem gespeichert!
'' Application.DisplayAlerts = False
' If bln = False Then
' Cancel = True
' bln = True
' ThisWorkbook.SaveAs Filename:=FileDestination
' ThisWorkbook.Save
' ThisWorkbook.Saved = True
' bln = False
' End If
'' Application.DisplayAlerts = True
' FileCopy FileSource, FileDestination
ThisWorkbook.SaveAs Filename:=FileDestination
ThisWorkbook.SaveAs Filename:=FileSource
ENDE:
End Sub