Dim Rep As String
Rep = Application.Proper(MonthName(Month(Date))) & " " & Year(Date) & " " & Year(Now)
Rep = Application.Proper(Format(Date,"mmmm yy")) & " " & Year(Now)bonsoir a tous et toutes
je voudrais intégré l'année en cours dans cette ligne de code mais je ne sais pas comment m'y prendre
Code:Dim Rep as String Rep = Application.Proper(MonthName(Month(Date))) & " " & Year(Date)
Private Sub CommandButton1_Click()
Application.DisplayAlerts = False
Dim Chemin As String, Fichier As String, Rep As String
Chemin = "C:\Users\Pascal\Desktop\testsave\"
'Chemin = ThisWorkbook.Path & "\"
'créer un dossier avec le nom du mois et l'année en cours
'si le mois change un autre dossier est créer
' Rep = Application.Proper(MonthName(Month(Date))) & " " & Year(Date)
'Rep = Application.Proper(MonthName(Month(Date))) & " " & Year(Date) & " " & Year(Now)
Rep = Application.Proper(Format(Date, "mmmm yy")) & " " & Year(Now)
'gestion des erreurs
On Error Resume Next
'définition du chemin
MkDir Chemin & Rep
On Error GoTo 0
Chemin = Chemin & Rep & "\"
Sheets("Feuil1").Copy
'copie de la feuille en ajoutant F devant le n° qui est en "C4" et +la date
Fichier = Sheets("Feuil1").Range("C4") & " " & "F" & Format(Date, "ddmmyyyy") & ".Pdf"
With ActiveWorkbook
'code qui enregistre en .pdf
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Chemin & Fichier, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
From:=1, To:=1, OpenAfterPublish:=False
'ferme le classeur créer
.Close savechanges:=False
'retabli les arlertes windows
Application.DisplayAlerts = True
'message pour dire que le fichier a bien été enregistrer
'que le chemin est bon
MsgBox ("Enregistré dans le dossier -Factures-")
End With
End Sub
Chemin = "C:\Users\Pascal\Desktop\testsave\2017\"
Rep = Application.Proper(MonthName(Month(Date)))
Private Sub CommandButton1_Click()
Dim Chemin As String, Nom As String, Fichier As String
Chemin = ThisWorkbook.Path & "\" & Year(Now) & "\"
On Error Resume Next
Application.DisplayAlerts = 0 'attention, fichier écrasé sans préavis !
MkDir Chemin
Nom = Feuil1.[C4] & " F " & Application.Proper(Format(Now, "mmmm yyyy"))
Fichier = Nom & ".Pdf"
ThisWorkbook.ExportAsFixedFormat 0, Chemin & Fichier, 1, 1, 0, 1, 1, 0
Application.DisplayAlerts = 1
'si pas utile, effacer la ligne suivante
MsgBox Nom & vbLf & " en Pdf" & vbLf & "dans le dossier " & Left(Chemin, Len(Chemin) - 1), , "Enregistré sous le nom "
End Sub
Chemin = "C:\Users\Pascal\Desktop\testsave & " \ " & Year(Now) & " \ ""
Chemin = "C:\Users\Pascal\Desktop\testsave\ " & Year(Now) & " \ """
ThisWorkbook.ExportAsFixedFormat 0, Chemin & Fichier, 1, 1, 0, 1, 1, 0