-
Dateiname bei "Speichern" vorgeben
Der Code muss unter “DieseArbeitsmappe” eingetragen werden.
[vba]
Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Pfad As String
Dim DateiName As String
Application.EnableEvents = FALSE
Pfad = Application.ActiveWorkbook.Path
If Application.ActiveWorkbook.Path = "" Then
Pfad = Environ("UserProfile") & "\Desktop\"
DateiName = Pfad & Left(ActiveSheet.Cells(1, 1).Value, 9) & "_Export_" & Format(Now, "YYYYMMDD")
' Speichere den Datei-Dialog mit Dateityp .xlsm
Application.Dialogs(xlDialogSaveAs).Show DateiName, xlOpenXMLWorkbookMacroEnabled ' Dateityp für .xlsm
Cancel = TRUE
Else
ActiveWorkbook.Save
Cancel = TRUE
End If
Application.EnableEvents = TRUE
End Sub
[/vba]
Sorry, there were no replies found.
Log in to reply.