Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1060to1064
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Datum bei speichern formatieren

Datum bei speichern formatieren
18.03.2009 13:29:56
Timmy
Liebe Excler,
ich habe folgendes Problem:
Ich habe ein Tabellenblatt mit einem Save_Button, der mir das Blatt unter einem bestimmten Namen speichert, je nachdem wie ich meine Felder befuelle. Z.B. koennte der Dateiname so ausshen:
Fastcap-Max Mustermann-Ich AG-03/18/2009.xls
das kann ich jedoch nicht speichern, da "/" nicht zulaessig ist.
Ich habe das Feld, in dem das Datum steht bereits anders formatiert, und zwar zu March 18, 2009, aber er zeigt mir es trotzdem noch so an und weigert sich zu speichern.
Ich hoffe, jemand weiss, wie ich das bewerkstelligen kann.
Vielen Dank und liebe Gruesse
Timmy

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Datum bei speichern formatieren
18.03.2009 13:43:54
Oberschlumpf
Hi Timmy
Ich würde den Dateinamen zuerst einer Variablen zuweisen
lstrFile = "Fastcap-Max Mustermann-Ich AG-03/18/2009.xls"
und dann die / gegen z Bsp - austauschen
lstrFile = Replace(lstrFile, "/", "-")
jetzt müsste der Inhalt von lstrFile so aussehen:
"Fastcap-Max Mustermann-Ich AG-03-18-2009.xls"
Und Speichern sollte nun auch gehen.
Hilfts, oder muss das Datum in deutscher Schreibweise vorhanden sein?
Ciao
Thorsten
AW: Datum bei speichern formatieren
18.03.2009 13:44:30
Tino
Hallo,
steht dieses Datum in einer Zelle,
wandle dieses Datum in ein passendes Format z. Bsp. mit unterstrich als Trennung.
Den Unterstrich verwende ich meist.
Bsp.
Dim sFileName As String
sFileName = _
            "Fastcap-Max Mustermann-Ich AG-" & _
            Format(Range("A1"), "mmmm_dd_yyyy") & _
            ".xls"


Gruß Tino

Anzeige
AW: Datum bei speichern formatieren
18.03.2009 15:05:47
Tino
Hallo,
ich vermute mal, dass besagt Datum steht in FastcapSaveNamePart3?
Versuche es mal so.

FastcapSaveNamePart3 = Format(ThisWorkbook.Sheets("Fastcap").Range("H6"), "mmmm_dd_yyyy") 


Gruß Tino

AW: Perfekt.....
18.03.2009 15:23:13
Timmy
Hi Tino,
du bist ein Schatz ;-)
es klappt super, und er speichert mir auch endlich meine Datei!!!
muchas gracias!!!!!
Timmy
AW: Datum bei speichern formatieren
18.03.2009 13:54:56
Timmy
Vielen Dank fuer die schnellen Antworten,
ich habe versucht, eure Anweisungen zu befolgen, aber ich kriege es nicht hin.
Ich bin mir sicher, dass ihr mich richtig beraten habt, nur baue ich den Code wahrscheinlich falsch um.
Ich weiss nicht, ob der Code optimal ist, aber er funktioniert wietesgehend ;-) ... bis auf das Problem mit dem Speichern zwecks des Datums!
Ich habe ihn nachstehend eingefuegt:

Private Sub FastcapSaveButton1_Click()
On Error GoTo showErrorMsg
Dim FastcapSaveNamePart1 As String
Dim FastcapSaveNamePart2 As String
Dim FastcapSaveNamePart3 As String
Dim FastcapSaveNamePart4 As String
Dim FastcapSaveName As String
'checks if all necessary information required in order to save the Fastcap is given
'if it is not, a message box to each one of the missing data appears
If Not Sheets("Fastcap").Range("AW16") = "4boxesok" Then
If Sheets("Fastcap").Range("H10") = "" Then
MsgBox ("Please select the appropriate Hardware Consultant." & vbLf & _
"Afterwards you can use the Save Fastcap-Button to save the worksheet."),  _
vbOKOnly, "Missing Name of HHC"
End If
If Sheets("Fastcap").Range("H6") = "" Then
MsgBox ("Please submit a date." & vbLf & _
"Afterwards you can use the Save Fastcap-Button to save the worksheet."),  _
vbOKOnly, "Missing date submitted"
End If
If Sheets("Fastcap").Range("X6") = "" Then
MsgBox ("Please give the Company Name." & vbLf & _
"Afterwards you can use the Save Fastcap-Button to save the worksheet."),  _
vbOKOnly, "Missing Company Name"
End If
If Sheets("Fastcap").Range("X10") = "" Then
MsgBox ("Please provide the Contact Name of the Customer." & vbLf & _
"Afterwards you can use the Save Fastcap-Button to save the worksheet."),  _
vbOKOnly, "Missing Contact Name"
End If
End If
'Checks if all yellow fields are filled out, if there are not, a message box appears
If Sheets("Fastcap").Range("AW19") > 0 Then
MsgBox ("Please note that all yellow fields must be completed," & vbLf & _
"in order to save this document."), vbOKOnly, "Fastcap Custom Color Request"
End If
If Worksheets("Fastcap").Range("X15") = "" Then
Worksheets("Data").Range("L29") = Now()
Worksheets("Data").Range("L29").NumberFormat = "MM.DD.YYYY"
FastcapSaveNamePart1 = ThisWorkbook.Sheets("Fastcap").Range("H10")       'Name of HHC
FastcapSaveNamePart2 = ThisWorkbook.Sheets("Fastcap").Range("X6")      'Company Name
FastcapSaveNamePart3 = ThisWorkbook.Sheets("Fastcap").Range("H6")      'Date
FastcapSaveNamePart4 = ThisWorkbook.Sheets("Data").Range("X10").Text   'Contact Name
FastcapSaveName = "Fastcap-" & FastcapSaveNamePart1 & "-" & FastcapSaveNamePart2 & "-" &  _
FastcapSaveNamePart3 & "-" & FastcapSaveNamePart4 & ".xls"
Application.Dialogs(xlDialogSaveAs).Show (FastcapSaveName)
End If
GoTo endSubOrFunction
showErrorMsg:
MsgBox "ERROR OCCURES: " & vbNewLine & vbNewLine & _
"Please contact CSR Department!" & vbNewLine & _
vbNewLine & _
"Source: ThisWorkbook.FastcapSaveButton" & vbNewLine & _
Err.Description & " [#" & Err.Number & "]", vbCritical, "Error message"
endSubOrFunction:
End Sub


Gruss
Timmy

Anzeige
Bsp-Datei?
18.03.2009 13:57:45
Oberschlumpf
Hi Timmy
Zumindest ich würd ne Bsp-Datei mit dem Code als nur den Code besser finden.
Ciao
Thorsten
AW: wird gemacht ;-)
18.03.2009 14:04:14
Timmy
Hi Thorsten,
da die Datei ueber 5MB hat, habe ich das Sheet einfach rauskopiert, bzw. einen Teil daraus.
Jetzt tritt natuerlich ein Fehler auf, dieser tritt aber in der originaldatei nicht auf, da diese ja vollstaendig ist.
Hier die Datei:
https://www.herber.de/bbs/user/60417.xls
Ich schaetze eure Hilfe sehr, da ich daran echt schon so lange rumexperimentiere ;-)
Gruss
Timmy

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige