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