1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Option Explicit
Private Declare Function SHCreateDirectoryEx Lib "Shell32.dll" Alias "SHCreateDirectoryExA" _
(ByVal hwnd As Long, ByVal pszPath As String, ByVal lngsec As Long) As Long
Private Function CreationDossier(Dossier As String) As Long
CreationDossier = SHCreateDirectoryEx(0&, Dossier, 0&)
End Function
Private Sub Impression(Fichier As String, y As String)
Dim sDossier As String
If MsgBox("Voulez-vous imprimer la commande?", vbYesNo) = vbNo Then Exit Sub
sDossier = ThisWorkbook.Path & "\" & y
With Feuil1
.Activate
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & Fichier, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
CreationDossier sDossier
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sDossier & "\" & Fichier, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
End Sub
Sub Tst()
Dim y As String
Dim sFichier As String
y = Year(Feuil1.Range("B18"))
sFichier = "Essai.pdf"
Impression sFichier, y
End Sub |
Partager