MuscatMimi
XLDnaute Accro
Bonjour a tous
Avec PDFCreator,je n'arrive pas a trouver la bonne syntaxe
pour enregistrer dans deux dossiers différends
voir ligne en commentaire "ICI" dans OptionButton1 et OptionButton2
Voici Le Code de base de PDFCreator
Merci a l'avance
Cordialement
Avec PDFCreator,je n'arrive pas a trouver la bonne syntaxe
pour enregistrer dans deux dossiers différends
voir ligne en commentaire "ICI" dans OptionButton1 et OptionButton2
Voici Le Code de base de PDFCreator
Code:
[COLOR=BLUE]Private Sub[/COLOR] CommandButton1_Click()
[COLOR=BLUE]Dim[/COLOR] outName [COLOR=BLUE]As String[/COLOR], i [COLOR=BLUE]As Long[/COLOR]
[COLOR=GREEN]'**If InStr(1, ActiveWorkbook.Name, ".", vbTextCompare) > 1 Then[/COLOR]
[COLOR=GREEN]'**outName = Mid(ActiveWorkbook.Name, 1, InStr(1, ActiveWorkbook.Name, ".", vbTextCompare) - 1)[/COLOR]
[COLOR=GREEN]'**Else[/COLOR]
[COLOR=BLUE]If[/COLOR] Range("B16").Value = "" [COLOR=BLUE]And[/COLOR] Range("B17").Value = "" [COLOR=BLUE]Then Exit Sub[/COLOR]
outName = Sheets("settings").Range("B16") & "_" & Range("B17") [COLOR=GREEN]'ActiveWorkbook.Name[/COLOR]
[COLOR=GREEN]'**End If[/COLOR]
CommandButton1.Enabled = [COLOR=BLUE]False[/COLOR]
[COLOR=BLUE]If[/COLOR] OptionButton1.Value = [COLOR=BLUE]True Then[/COLOR]
[COLOR=BLUE]With[/COLOR] PDFCreator1
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = ActiveWorkbook.path & "\Temp"
[COLOR=GREEN]'.cOption("AutosaveDirectory") = ActiveWorkbook.path & "\Sauvegarde" ICI[/COLOR]
.cOption("AutosaveFilename") = outName
.cOption("AutosaveFormat") = 0 [COLOR=GREEN]' 0 = PDF[/COLOR]
.cClearCache
[COLOR=BLUE]End With[/COLOR]
[COLOR=BLUE]For[/COLOR] i = 1 [COLOR=BLUE]To[/COLOR] Application.Sheets.Count
Application.Sheets(i).PrintOut Copies:=1, ActivePrinter:="PDFCreator"
[COLOR=BLUE]Next[/COLOR] i
[COLOR=BLUE]Do Until[/COLOR] PDFCreator1.cCountOfPrintjobs = Application.Sheets.Count
DoEvents
Sleep 1000
[COLOR=BLUE]Loop[/COLOR]
Sleep 1000
PDFCreator1.cCombineAll
Sleep 1000
PDFCreator1.cPrinterStop = [COLOR=BLUE]False[/COLOR]
[COLOR=BLUE]End If[/COLOR]
[COLOR=BLUE]If[/COLOR] OptionButton2.Value = [COLOR=BLUE]True Then[/COLOR]
[COLOR=BLUE]With[/COLOR] PDFCreator1
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = ActiveWorkbook.path & "\Temp"
[COLOR=GREEN]'.cOption("AutosaveDirectory") = ActiveWorkbook.path & "\Sauvegarde" ICI[/COLOR]
[COLOR=BLUE]Debug.Print[/COLOR] outName & "-" & ActiveSheet.Name
.cOption("AutosaveFilename") = outName [COLOR=GREEN]'& "-" & ActiveSheet.Name[/COLOR]
.cOption("AutosaveFormat") = 0 [COLOR=GREEN]' 0 = PDF[/COLOR]
.cClearCache
[COLOR=BLUE]End With[/COLOR]
ActiveSheet.PrintOut Copies:=1, ActivePrinter:="PDFCreator"
[COLOR=BLUE]Do Until[/COLOR] PDFCreator1.cCountOfPrintjobs = 1
DoEvents
Sleep 1000
[COLOR=BLUE]Loop[/COLOR]
Sleep 1000
PDFCreator1.cPrinterStop = [COLOR=BLUE]False[/COLOR]
[COLOR=BLUE]End If[/COLOR]
[COLOR=BLUE]End Sub[/COLOR]
Merci a l'avance
Cordialement