Finde Antworten, stelle Fragen und schließe dich mit unserer Community zusammen.

Startseite Forums Excel VBA Code Snippets Dateiname bei "Speichern" vorgeben

Tagged: 

  • Dateiname bei "Speichern" vorgeben

    Posted by Excel Community on 6. September 2024 at 21:53

    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]

    Excel Community replied 2 months, 2 weeks ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.