Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim semaine As String
Option Explicit
Dim semaine As String
Dim path As String
Private Sub CommandButton2_Click()
semaine = Range("A1") 'a adapter
dossier 'création dossier
chemsave = path & semaine & "\"
End Sub
Sub dossier()
path = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\"
If Len(Dir(path & semaine, vbDirectory)) = 0 Then 'chemin a adapter
MkDir path & semaine
End If
End Sub
Sub ToPdf()
Dim chemsave As String
chemsave = "C:\chemin dossier destination\" 'chemin destination
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
'NomExcel = ThisWorkbook.Name
'NomPdf = Left(NomExcel, Len(NomExcel) - 4) & ".pdf"
With pdfjob
If .cstart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutisaveDirectory") = 1
.cOption("AutosaveDirectory") = chemsave 'chemin destination
.cOption("AutosaveFilename") = UserForm1.ComboBox1.Value & ".pdf" 'nom de la feuille
.cOption("AutosaveFormat") = 0
.cClearCache
End With
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=32766, Copies:=1, ActivePrinter:="PDFCreator" 'on imprime la feuille active
'ThisWorkbook.PrintOut Copies:=1, ActivePrinter:="PDFCreator"
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
With pdfjob
.cDefaultprinter = DefaultPrinter
.cClearCache
.cClose
End With
Set pdfjob = Nothing
MsgBox "Votre PDF se trouve à cet emplacement: " & chemsave, vbInformation, "Convertir en PDF"
End Sub
Sub ToPdf()
If chemsave = "" Then Exit Sub
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
'NomExcel = ThisWorkbook.Name
'NomPdf = Left(NomExcel, Len(NomExcel) - 4) & ".pdf"
With pdfjob
If .cstart("/NoProcessingAtStartup") = False Then
MsgBox "Can't initialize PDFCreator.", vbCritical + vbOKOnly, "PrtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutisaveDirectory") = 1
.cOption("AutosaveDirectory") = chemsave 'chemin destination
.cOption("AutosaveFilename") = UserForm1.ComboBox1.Value & ".pdf" 'nom de la feuille
.cOption("AutosaveFormat") = 0
.cClearCache
End With
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=32766, Copies:=1, ActivePrinter:="PDFCreator" 'on imprime la feuille active
'ThisWorkbook.PrintOut Copies:=1, ActivePrinter:="PDFCreator"
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
With pdfjob
.cDefaultprinter = DefaultPrinter
.cClearCache
.cClose
End With
Set pdfjob = Nothing
MsgBox "Votre PDF se trouve à cet emplacement: " & chemsave, vbInformation, "Convertir en PDF"
End Su
Private Sub CommandButton2_Click()
semaine = Range("AZ10")
dossier 'création dossier
chemsave = path & "pointage-S" & semaine & "\"
End Sub
Sub dossier()
path = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\"
If Len(Dir(path & "pointage-S" & semaine, vbDirectory)) = 0 Then
MkDir path & "pointage-S" & semaine
End If