AW: bleiben noch zwei Fragen...
Josef
Hallo Jörg,
zu 1.: Meines Wissens gar nicht, zumindest nicht mit diesem Dialog.
Zu 2.: Dazu braucht man eine öffentliche Variable und ein paar Zeilen Code unter "DieseArbeitsmappe"
' **********************************************************************
' Modul: Modul4 Typ: Allgemeines Modul
' **********************************************************************
Option Explicit
Public blnSave As Boolean
Private Function GetFolder(Optional Path As String = "", Optional Title As String = "") As String
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.InitialFileName = Path
.ButtonName = "OK"
.Title = IIf(Len(Title), Title, "Ordner wählen")
.Show
If .SelectedItems.Count = 0 Then
GetFolder = ""
Else
GetFolder = .SelectedItems(1)
End If
End With
End Function
Sub saveFile()
Dim strFileName As String, strPath As String
On Error GoTo ErrExit
Application.DisplayAlerts = False
strFileName = "deinedatei.xls"
strPath = GetFolder("C:\" & strFileName, "Wählen Sie einen Ordner")
If Len(strPath) Then
If Dir(strPath & "\" & strFileName, vbNormal) <> "" Then
If MsgBox("Die Datei" & vbLf & vbLf & strPath & "\" & strFileName & vbLf & _
vbLf & "ist bereits vorhanden!" & vbLf & "Soll die Datei ersetzt werden?", _
vbQuestion + vbYesNo, "Speichern") = vbNo Then Exit Sub
End If
blnSave = True
ActiveWorkbook.SaveAs strPath & "\" & strFileName
blnSave = False
End If
ErrExit:
Application.DisplayAlerts = True
End Sub
' **********************************************************************
' Modul: DieseArbeitsmappe Typ: Element der Mappe(Sheet, Workbook, ...)
' **********************************************************************
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Not blnSave Then
Cancel = True
MsgBox "Speichern nur über die dafür vorgesehene Schaltfläche!", _
vbInformation, "Speichern"
End If
End Sub
Gruß Sepp