Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

sauvegarde PDF

4 réponses
Avatar
sunburn
Bonjour,
comment dans mon userform, je peux proposer la sauvegarde en PDF ?

je vous remercie (excel 2003 SP3).

YANN

4 réponses

Avatar
sunburn
re,
pour précision, je voudrais savoir s'il est possible dans mon userform, de
mettre un bouton "sauvegarde PDF".
en cliquant sur ce bouton, il y aurait un enregistrement automatique au
format PDF, sans avoir un écran d'impression.
L'endroit de l'enregistrement serais un sous-dossier "PDF" où est enregistré
le fichier Excel.

Merci de votre aide.

YANN
Avatar
sunburn
Re,
j'avance petit à petit. j'ai installé PDF Creator.
Puis, j'ai ce code ci-apres, mais le hic, c'est que je voudrais avoir 1 seul
fichier de généré, dont le nom est "choix1" (par exemple), et je voudrais
préciser le chemin d'enregistrement si c'est possible (facultatif).
Le PLUS important et TRES important pour moi, c'est la création d'UN SEUL
FICHIER PDF,avec un nom prédéfini.

Si vous pouvez m'aider, j'en serais ravi.
YANN

code actuel (choix 2 et 3) :
------
If EcranImprimer.Choix2 Then
'Imprime le dossier de contrôle annuel
'Imprimante = Application.Dialogs(xlDialogPrinterSetup).Show 'lance la
boite de dialogue Choix de l'imprimante
'If Imprimante = "Vrai" Then
ActiveWorkbook.Unprotect
NP = Worksheets.Count
For I = Sheets("DA").Index To NP 'imprime les onglets de DA au dernier
Set Sh = Sheets(I)
If Not UCase(Trim(Sh.Cells(4, 1).Value)) = "NA" Then
Debug.Print Sh.Name
memVisible = Sh.Visible
Sh.Visible = True
Sh.PrintOut copies:=1, ActivePrinter:="PDF Creator",
Collate:=True
Sh.Visible = memVisible
End If
Next
Unload Me
ActiveWorkbook.Protect Structure:=True 'protection du classeur
'End If
'Unload Me
Else
End If

If EcranImprimer.Choix3 Then
'imprime le dossier général du COLLABORATEUR + balances + FS
'Imprimante = Application.Dialogs(xlDialogPrinterSetup).Show 'lance la
boite de dialogue Choix de l'imprimante
'If Imprimante = "Vrai" Then
ActiveWorkbook.Unprotect
For Each Sh In Sheets(Array("DGA", "GA02", "GA10", "GA11", "GA12",
"GA13", "GA14", "FSF", "FSP")) 'imprime les onglets sélectionnés
If Not UCase(Trim(Sh.Cells(4, 1).Value)) = "NA" Then
Debug.Print Sh.Name
memVisible = Sh.Visible
Sh.Visible = True
Sh.PrintOut copies:=1, ActivePrinter:="PDF Creator",
Collate:=True
Sh.Visible = memVisible
End If
Next
Unload Me
ActiveWorkbook.Protect Structure:=True 'protection du classeur
'End If
'Unload Me
Else
End If
------
Avatar
isabelle
bonjour Yann,

voici un exemple trouver sur :

'http://www.excel-downloads.com/forum/112586-edition-pdf.html
Autheur: GGAL

Sub printtest_1()
'La feuille active.
a = ActiveSheet.Name
Call printsheetinpdf(Sheets(a))
End Sub

Sub printtest_2()
'Quelques feuilles du classeur, à adapter.
a = ActiveSheet.Name
b = "Annexe"
c = Sheets(3)
Call printsheetinpdf(Sheets(Array(a, b, c)))
End Sub

Sub printtest_3()
'Le classeur entier.
Call printsheetinpdf(ActiveWorkbook)
End Sub

Sub printsheetinpdf(shsheet As Object)
Dim pdfjob As Object
Dim spdfname As String
Dim spdfpath As String
spdfname = "Fiche navette_" & Range("h8") & "_" & Format(Date,
"dd-mm-yyyy") & ".pdf" 'Nom du fichier, à adapter
spdfpath = "c:zz" 'Documents and Settings" &
UCase(Environ("username")) & "Mes documents" 'Nom du chemin, à adapter
Call killtask("PDFCreator.exe")
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
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") = spdfpath
.cOption("AutosaveFilename") = spdfname
.cOption("AutosaveFormat") = 0
.cClearCache
End With
shsheet.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
Application.Wait (Now + TimeValue("0:00:3"))
.cClose
End With
Set pdfjob = Nothing
End Sub

Sub killtask(sappname As String)
Dim oProclist As Object
Dim oWMI As Object
Dim oProc As Object
Set oWMI = GetObject("winmgmts:")
If IsNull(oWMI) = False Then
Set oProclist = oWMI.InstancesOf("win32_process")
For Each oProc In oProclist
If UCase(oProc.Name) = UCase(sappname) Then
oProc.Terminate (0)
End If
Next oProc
Else
MsgBox "Killing """ & sappname & """ - Can't create WMI
Object.", vbOKOnly, vbCritical, "CloseAPP_B"
End If
Set oProclist = Nothing
Set oWMI = Nothing
End Sub

isabelle

sunburn a écrit :
Bonjour,
comment dans mon userform, je peux proposer la sauvegarde en PDF ?

je vous remercie (excel 2003 SP3).

YANN



Avatar
sunburn
Merci Isabelle,
j'essaye d'adapter ce code, mais je t'avoue que c'est assez complexe.
le lien est mort (chez moi an tout cas)
j'essaye le test 2 (celui qui va bien pour mes impressions de pages
spéciales).
j'ai essayé avec 2 onglets, mais il n'en imprime qu'un...
J'ai un peu de mal.
je continue de chercher, merci deja pour le code.

YANN

"isabelle" a écrit :

bonjour Yann,

voici un exemple trouver sur :

'http://www.excel-downloads.com/forum/112586-edition-pdf.html
Autheur: GGAL

Sub printtest_1()
'La feuille active.
a = ActiveSheet.Name
Call printsheetinpdf(Sheets(a))
End Sub

Sub printtest_2()
'Quelques feuilles du classeur, à adapter.
a = ActiveSheet.Name
b = "Annexe"
c = Sheets(3)
Call printsheetinpdf(Sheets(Array(a, b, c)))
End Sub

Sub printtest_3()
'Le classeur entier.
Call printsheetinpdf(ActiveWorkbook)
End Sub

Sub printsheetinpdf(shsheet As Object)
Dim pdfjob As Object
Dim spdfname As String
Dim spdfpath As String
spdfname = "Fiche navette_" & Range("h8") & "_" & Format(Date,
"dd-mm-yyyy") & ".pdf" 'Nom du fichier, à adapter
spdfpath = "c:zz" 'Documents and Settings" &
UCase(Environ("username")) & "Mes documents" 'Nom du chemin, à adapter
Call killtask("PDFCreator.exe")
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
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") = spdfpath
.cOption("AutosaveFilename") = spdfname
.cOption("AutosaveFormat") = 0
.cClearCache
End With
shsheet.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
Application.Wait (Now + TimeValue("0:00:3"))
.cClose
End With
Set pdfjob = Nothing
End Sub

Sub killtask(sappname As String)
Dim oProclist As Object
Dim oWMI As Object
Dim oProc As Object
Set oWMI = GetObject("winmgmts:")
If IsNull(oWMI) = False Then
Set oProclist = oWMI.InstancesOf("win32_process")
For Each oProc In oProclist
If UCase(oProc.Name) = UCase(sappname) Then
oProc.Terminate (0)
End If
Next oProc
Else
MsgBox "Killing """ & sappname & """ - Can't create WMI
Object.", vbOKOnly, vbCritical, "CloseAPP_B"
End If
Set oProclist = Nothing
Set oWMI = Nothing
End Sub

isabelle

sunburn a écrit :
> Bonjour,
> comment dans mon userform, je peux proposer la sauvegarde en PDF ?
>
> je vous remercie (excel 2003 SP3).
>
> YANN
>